|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi there,
I have a form (in ASP) that has three objects. When the page loads the combo box fills up with information about members details: NAME and AGE. The two text boxes are empty. 1> drop down combo box (date: name and age) 2> text input box 3> 2nd text input box What I need to do When a user selects a member from the drop down box, I want the information in the drop down box to automatically appear in the two text boxes. The NAME must go in the first text box. The AGE must go in the second text box. I am not sure is I need a JavaScript function to do this? Would appreciate any advice. Thanks. |
|
#2
|
|||
|
|||
|
hey dukey
first tell the how you will bring the data of select change of combo . because javascript will not go to server. and as u said that you have dynamically filled combo. so do one thing cache the data in javascript at the same time in when u fill the combo box, or set user defined attributes. when u will see the rendered code it will look like <select> <option value="some Value" userdefinedAttrName="some value" userdefinedAttrAge="some value">display value</option> </select> then use this function on select change function fn_InsertMyValues(e,txtName,txtAge) { if(e.options.selectedIndex!=0)// if no values on index 0 { document.getElementById(txtName).value=e.options[e.options.selectedIndex].userdefinedAttrName document.getElementById(txtAge).value=e.options[e.options.selectedIndex].userdefinedAttrAge; } } enjoy |
|
#3
|
||||
|
||||
|
if your taking it this way...
you could you cookies to store info and getinfo from, although it may be deleted by user... anyway the helpful cookie coding is... function getCookie( name ) { var start = document.cookie.indexOf( name + "=" ); var len = start + name.length + 1; if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) { return null; } if ( start == -1 ) return null; var end = document.cookie.indexOf( ";", len ); if ( end == -1 ) end = document.cookie.length; return unescape( document.cookie.substring( len, end ) ); } function setCookie( name, value, expires, path, domain, secure ) { var today = new Date(); today.setTime( today.getTime() ); if ( expires ) {expires = expires * 1000 * 60 * 60 * 24;} var expires_date = new Date( today.getTime() + (expires) ); document.cookie = name+"="+escape( value ) + ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString() ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" ); } function deleteCookie( name, path, domain ) { if ( getCookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; } |
|
#4
|
|||
|
|||
|
only one thing to say that cookies are old methods and quite obselete. and now a days due to hacking client user normally disable the cookie so u will stay on the mercy f t he client user
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Dynamically moving dataon a page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|