Jump to content

remove combobox


ki

Recommended Posts

ok, if any of you have facebook you know what im going to ask
how 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?
Link to comment
Share on other sites

Here is some code I wrote for another application.
1) The Combo box has an "Other" entry whose value is -1
2) 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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.