Jump to content

remove combobox


ki

Recommended Posts

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
https://forums.phpfreaks.com/topic/31447-remove-combobox/#findComment-146069
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.