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
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Wanting to "Write" <Select> box chosen value

    I have dynamic data being loaded into a select box.
    Trying to capture the user's selected option "value" and then "write" the value into a field for editing.

    Problem one: option isn't captured by title variable. (Source code proof)
    Problem two: input box value = "<script type='text/javascript'> write('title'); </script>"

    Code:
    <script type="text/javascript">
    function choice(){
    	var title = document.courses.value"";
    }
    </script>
    <select name="courses" id="courses" onchange="choice()">
    <option value="Please Choose One">Please Choose One</option>n/
    <option  value="Bible">Bible</option>n/
    <option value="Christian Ethics">Christian Ethics</option>n/
    <option  value="Church History">Church History</option>n/
    <option value="Homiletics">Homiletics</option>
    </select>
    <br>
    Chosen course: <input type="text" size="30" value="<script type='text/javascript'> write('title'); </script>">

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    well you have "" in there for some reason na dyou are reference the form field wrong.

    correct way to reference a value in a dropdown list is

    Code:
    var sel = document.forms[0].selectName;
    var selValue = sel.options[sel.selectedIndex].value;
    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Got it now. Thanks.


  •  

    Posting Permissions

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