View Full Version : Get selected value from Value List

03-11-2004, 04:06 PM
I am trying to get a selected value from a value list from one form and enter it into a value in a second form for submission. I have accomplished this when the first field is a text field, but when I change it to a value list I cannot seem to get the selected value.

1st form name = example
2nd form name = form1

From form "example" select name="pichoice"

function setTokens(){
var selectone = document.example.pichoice;
var name1 = selectone.options[selectone.selectedIndex].value;
document.form1.elements ["profiles::pi_full_name"] .value = name1;

Can anyone see what I am doing wrong?

I tried several different things last night with no success. I attempled to display whatever value was retreived from the selected value, sometimes I got nothing and other times I goth the text "[option]"

Thanks in advance for your help!!

03-11-2004, 06:59 PM
Can we see the HTML of your select box (btw, is a 'value list' a select box? because that's got me a little confused here...)

I'm thinking that perhaps your options are like so:

<select ...>

whereas the options should look more like:

<option value="blah">blah</option>

If you haven't set the value attribute, I don't think you can reference it and expect to get a value.

Aside from that, I don't actually see anything wrong with that part, although the line with the smiley face looks odd..

Hope that helps,

03-11-2004, 08:09 PM
Yes, you were right about the way the options were displaying. I was able to fix it by changing .value to .text and it now populates the variable.

The smiley face must have been some weird interpretation of the double colon I used.

Thank you for your help!