PDA

View Full Version : select menu to text menu


Ultragames
04-25-2005, 09:53 PM
I need to change me select menu to a text box when the user selects one of the options, with the value of 'manual'

I tried something using document.form.foobar.type = 'text'; but a select dosnt have a type. It should work if the select were a checkbox or something, but its not.

How can I do this?

sidvorak
04-25-2005, 11:38 PM
Let's see some of your code. This should be easy to do using the DOM.

glenngv
04-26-2005, 07:20 AM
I need to change me select menu to a text box when the user selects one of the options, with the value of 'manual'

I tried something using document.form.foobar.type = 'text'; but a select dosnt have a type. It should work if the select were a checkbox or something, but its not.

How can I do this?
Once the select is changed to textbox, how would the user choose the other options if he decides to change his selection?

Ultragames
04-27-2005, 02:05 AM
Lets see what code? I havnt built the box yet. Im waiting to find out how to do this.

As far as chaning their mind, when they save the document, it will change back to a select with the manualy entered option in the menu, and selected. (with PHP) But i need to know how to change it from select to text box to do all of that.

glenngv
04-27-2005, 02:30 AM
As far as chaning their mind, when they save the document, it will change back to a select with the manualy entered option in the menu, and selected.
So the user cannot change his selection when the document is not yet saved? What if he just chose the wrong item and wants to change his selection at once?

You might want the Editable Type-ahead Combo (see my sig) rather than transforming the select box to textbox. It allows the user to type inside the select and add the item if it's not existing in the option items.

Ultragames
04-27-2005, 02:46 AM
I have scrapped the idea of multiple pulldowns. Here will be the options:

Current Date
Other

Other will become a text box. WHere they can change the date. Once the date is saved the options will be come this:

Current Date
-The date you entered- *Actualy prints the date
Other

As far as saving the thing goes, it is saved many time through the process anyways, so this is not a problem.

glenngv. Your code is impressive. However, to bulky for what im trying to do. I simply need a way for the select menu to change. I have seen this done on Godaddy.com email, but as i dont have an address, i can't see it in action.

glenngv
04-27-2005, 03:35 AM
I'm trying to find other ways as I think changing the select box to textbox is not user-friendly.

Why not show a textbox beside the combobox when "Other" is selected?

function checkOther(sel){
var optVal = sel.options[sel.selectedIndex].value;
if (optVal == "other"){
sel.form.otherdate.style.display="inline";
sel.form.otherdate.focus();
}
else{
sel.form.otherdate.style.display="none";
}
}

function init(){
//hide otherdate field
document.frm.otherdate.style.display="none";
}
...
<form name="frm">
<select name="selDate" onchange="checkOther(this)">
<option value="current">Current Date</option>
<option value="other">Other</option>
</select>
<input type="text" name="otherdate" title="Fill this out if you choose 'Other'" />
</form>

Ultragames
04-27-2005, 04:29 AM
I finaly solved the problem using style:display, and divs. The div that the select menu is inside, disapears, and the div the textbox appears, as well as a button next to the textbox, named 'Menu' that will bring back the select menu.

THanks for your help!

glenngv
04-27-2005, 05:16 AM
Have you considered my solution? I think mine is better as it's more intuitive and the select and textbox are still usable even if javascript is disabled.