Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - How to change a field based on user's selection in an HTML select? -


i have select list containing variables query

<tr>   <td>county name:</td>     <td>       <select name="countyname" onchange="countyid.value = countyname.value">                 <option>select county</option>         <cfloop query = "getcounties">         <option value="#countyname#" >#countyname#&nbsp;&nbsp;&nbsp;#countyid#</option>         </cfloop>     </select>     </td> </tr> 

how can populate county id field?

<tr>   <td>county id:</td>     <td><input type="text" name="countyid">      </td> </tr> 

i've never used jquery. there way use javascript? can see i've attempted javascript, can populate countyid countyname , need populated countyid.

breaking out function should work you: live example

<table>     <tbody>         <tr> <td>county id:</td> <td><input id="countyid" type="text" name="countyid"> </td> </tr>         <tr> <td>county name:</td>               <td>                  <select name="countyname" onchange="update(this)">                     <option>select county</option>                      <option value="1234">asdf</option>                      <option value="4321">asdf2</option>                  </select>              </td>         </tr>     </tbody> </table> <script>     function update( elem ) {     document.getelementbyid('countyid').value = elem.value;     } </script> 

or in short change

this:

<select name="countyname" onchange="countyid.value = countyname.value"> 

to this, , should work

<select name="countyname" onchange="document.getelementbyid('countyid').value = this.value"> 

you need reference dom elements via document.getelementbyid() , not id alone

another example here


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -