Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •