ki Posted December 21, 2006 Share Posted December 21, 2006 ok, if any of you have facebook you know what im going to askhow would you, if you select from a different option in the combo box it removes the combo box and makes a regular text box appear in the same place of the combo box with the same name and id and so on? Quote Link to comment Share on other sites More sharing options...
artacus Posted December 21, 2006 Share Posted December 21, 2006 Here is some code I wrote for another application.1) The Combo box has an "Other" entry whose value is -12) If the user selects Other, the items from the original list are stored in "holder" and the combo box is replaced with a text field. 3) If the user types "undo" into the text field, the process reverses, items are fetched out of "holder" and the combo box is restored.[code]function checkDest(myObj) { if (myObj.options[myObj.selectedIndex].value == -1) { //out of district replace combo box holder = document.getElementById('destination').innerHTML; document.getElementById('destination').innerHTML = '<input name="destination" value="Enter Destination" class="lgInput" onChange="undoDest(this);"/>'; } }function undoDest(myObj) { if (myObj.value == 'undo') { if (holder) { document.getElementById('destination').innerHTML = holder; } else { //copy from origin instead document.getElementById('destination').innerHTML = '<select name="end_point_id" id="end_point_id" onchange="checkDest(this);"></select>'; var spid = document.getElementById('start_point_id'); var epid = document.getElementById('end_point_id'); for (var i=0; i < spid.options.length; i++) { epid.options[i] = new Option (spid.options[i].text, spid.options[i].value); } epid.options[epid.options.length] = new Option('-Out of district-',-1); } }}[/code] Quote Link to comment Share on other sites More sharing options...
ki Posted December 23, 2006 Author Share Posted December 23, 2006 thanks, so would you use this using the onBlur or focus for the combobox and textfield Quote Link to comment Share on other sites More sharing options...
artacus Posted December 25, 2006 Share Posted December 25, 2006 onChange will work for both the combo box and textfield Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.