I am working on a project that will use a variety of selected menus to enter various data. I would like to include the βotherβ option directly in select, which will lead to a simple dialog and allow users to enter a custom value (if necessary), similar to the following javascript code:
<script type="text/javascript" language="javascript">
function chkother(fld,len,idx) {
if ((idx+1)==len) {
other=prompt("Please indicate 'other' value:");
fld.options[idx].value=other;
fld.options[idx].text=other;
}
}
</script>
which works with a choice:
<select onchange="chkother(this,this.options.length,this.options.selectedIndex)" name="example" id="example" class="formSelect">
<option value=""></option>
<option value="yes">yes</option>
<option value="no">no</option>
<option value="other">other</option>
</select>
And displays a tooltip that will update this feature using user text.
I would like to do something similar using jquery so that I can expand the possibilities and learn a bit of jquery, but I am having trouble running.
user238680
source
share