Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-11-2004, 03:06 PM   PM User | #1
allyson212
New to the CF scene

 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
allyson212 is an unknown quantity at this point
Get selected value from Value List

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:i_full_name"] .value = name1;
document.form1.submit();
}

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!!
Allyson
allyson212 is offline   Reply With Quote
Old 03-11-2004, 05:59 PM   PM User | #2
sad69
Senior Coder

 
Join Date: Feb 2004
Posts: 1,206
Thanks: 0
Thanked 0 Times in 0 Posts
sad69 is an unknown quantity at this point
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:
Code:
 <select ...>
  <option>blah</option>
  <option>blah2</option>
  ...
 </select>
whereas the options should look more like:
Code:
 <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,
Sadiq.
sad69 is offline   Reply With Quote
Old 03-11-2004, 07:09 PM   PM User | #3
allyson212
New to the CF scene

 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
allyson212 is an unknown quantity at this point
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!
allyson212 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:20 AM.


Advertisement
Log in to turn off these ads.