...

View Full Version : Changing From Button Use To Drop Down Menu



jojo
08-02-2002, 08:51 PM
Hi,

Here is my current bit of javascript;



<script>
function jsin(element) {
document.theform.page.value = document.theform.page.value + "\n element "; }
</script>

<form name="theform" action="file.htm" method=POST>
Click to insert:
<input type="button" value="Name"
onClick="jsin(Name);">
<input type="button" value="Age"
onClick="jsin(Age);">
....
...
</form>


That provides the user with boxes, and when they click on the box, the appropriate field gets put into the form.

My question is..
Instead of using boxes, how can I make a drop down menu that when the user clicks onto the appropriate field, it'll add it to the form?
Basically, I want to change the buttons for a drop down menu.

Can anyone please help me out here?

TX!!!

JohnKrutsch
08-02-2002, 11:32 PM
How about something like this:

<script>
function jsin(element) {
document.theform.page.value += "\n"+ element ; }
</script>

<form name="theform" action="file.htm" method=POST>
<select name="choices" onchange="if(this.selectedIndex!=0)jsin(this.options[this.selectedIndex].text)">
<option>Choose to insert</option>
<option>Name</option>
<option>Age</option>
</select>
<textarea cols="30" rows="10" name="page"></textarea>
</form>

jojo
08-04-2002, 06:20 AM
Great!! Thank you soooo much!

jojo
08-04-2002, 10:18 PM
One more question.

Right now, this only enters the text, not the value of the option.

IE; If my form has this;

<option value="Thank you for contacting our company!">Thank You</option>

It'll only add the words 'Thank You' to the form, and not the entire value. Is there a way to change that?

Thanks!

ShriekForth
08-05-2002, 03:04 PM
That will require only one change...

<select name="choices" onchange="if(this.selectedIndex!=0)jsin(this.options[this.selectedIndex].value)">

You want the value, of the option. Text is what is displayed.

ShriekForth

jojo
08-05-2002, 05:06 PM
Much obliged!

Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum