38 users online (0 members and 38 guests)  


  Results 1 to 9 of 9

Related

  1. Code to Change Picture Based on Drop Down Option Selected    Forum: Website Scripts Forum
    Replies: 9
  2. Drop Down menu Validation change mind?    Forum: Javascript Forum
    Replies: 1
  3. Replies: 2
  4. .au etc- does it affect rankings?    Forum: Search Engine Optimization - SEO - Forum
    Replies: 4
  1. #1
    hermoine's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    32

    Lightbulb change in drop down box should affect all the other fields

    Hello friends,
    If i change a drop down box, then all the other fields should change. But the values should be retrieved from the database.
    ex: If the drop down box contains students names. Then when i select one student name. then the details of that student should be displayed in the form.
    If it is not the database then we can use onchange() event.

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: change in drop down box should affect all the other fields

    Do you have some code that isn't working correctly? If so, please post it so we can see what you're trying to do. Thanks.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    hermoine's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    32

    Lightbulb Re: change in drop down box should affect all the other fields

    Code:
    function change(){
                document.frmsubmit.action="thisform.jsp?value="+document.frmsubmit.cmbbox.value;
                document.frmsubmit.submit();
     }
    i used it in onchange() event
    Code:
    <form name="frmsubmit" method="get" action="nextform.jsp" target="thisframe">
     
    <select name="cmbrdl" onchange="change()">
            <option value="a">a
            <option value="b">b
            <option value="c">c
    </select>
    this is not even pasing the value. Its really urgent. can you help me.

  4. #4
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: change in drop down box should affect all the other fields

    I don't know if this is the only problem, but this section of code isn't well formed.

    Code:
            <option value="a">a
            <option value="b">b
            <option value="c">c
    It should look like this instead:

    Code:
            <option value="a">a</option>
            <option value="b">b</option>
            <option value="c">c</option>
    Change that and see if that fixes your problem.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  5. #5
    hermoine's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    32

    Lightbulb Re: change in drop down box should affect all the other fields

    still not working.
    can you tell some other way to retrive the values?
    Actually if i select a value from the combobox then i need to be able to access that value through jsp.

  6. #6
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: change in drop down box should affect all the other fields

    Usin DOM (Document Object Model) scripting, the index of the item selected would be:

    Code:
    document.getElementById("frmsubmit").cmbrdl.selectedIndex
    Assign a variable to that index, for example:

    Code:
    ChosenValue = document.getElementById("frmsubmit").cmbrdl.selectedIndex;
    Then reference its value as:

    Code:
    document.getElementById("frmsubmit").cmbrdl[ChosenValue].value
    Use that in whatever you're calling to retrieve information from your database. I can't help you with the JSP portion of your problem. Sorry.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  7. #7
    hermoine's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    32

    Lightbulb Re: change in drop down box should affect all the other fields

    hi, thanks for reply.
    i my previous code itself if i use selectedIndex instead of value then i am able to retrive the index. and the form is opening in a new window. can you tell me a way to retrive the value and to submit the form targetted to the same window?
    I used your code.
    Code:
    ChosenValue = document.getElementById("frmsubmit").cmbrdl.selectedIndex;
    but it is saying
    object doesnot support this property or method.

  8. #8
    hermoine's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    32

    Lightbulb Re: change in drop down box should affect all the other fields

    hello,
    Code:
    form.target
    is helpful for targetting.

    can you give a way to retrieve the value of the selected item?

  9. #9
    hermoine's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    32

    Re: change in drop down box should affect all the other fields

    thanks a lot vinyl. you gave me the idea.
    Code:
    textBx.value = lstBx.options[lstBx.selectedIndex].text;
    i used the above code and got what i wanted.
    thanks a lot once again.



Tags for this Thread