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
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts

    What is the order of elements?

    I seem to have a standing problem with getting to elements through javascript.

    In this episode I have two selects on a form. When the select changes I want to submit the form after setting the value of the important field to the value of the select. My problem is that I can't get to the form let alone the field on the form.

    Code:
    <Form name="SurvForm" action="survey.asp" method="Post" id="SurvForm" >
    <select Size="1" name="ComSurv" onChange="DoSurvey(this)">
    <option Selected value="Select" />--------- Select --------- 
    <%
    While NOT RS.EOF
    	  %><option value= <% =RS("JobNumber") %> /> <% = RS("SurveyName") %>
    	  <% RS.MoveNext
    Wend %>
    </select>
    <input type="hidden" value="" name="JobNo" />
    </form>
    
    Scripts
    
    I am trying to get to the form that has the select as a child element.
    
    function DoSurvey(which){
    	alert("Doing Survey.  Getting " + which.value);
    	which.parent.form.jobNo.value=which.value;
    	which.parent.form.submit();
    }
    What is above is just the last WAG at what I am trying to get to.

    Thanks for looking.
    Scott Stewart
    Always happy to learn from pros.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    All form elements have a built-in reference to the form to which they belong, which is stored as

    element.form

    So, in your function, the parent is wrong, just use

    which.form.jobNo.value = which.options[which.selectedIndex].value;
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Thanks for your reply.

    Since this is personal stuff and I'm at work now, I'll try your code when I get a chance later today and see what happens.
    Scott Stewart
    Always happy to learn from pros.


  •  

    Posting Permissions

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