Jump to content


OnClick Function Help

  • Please log in to reply
1 reply to this topic

#1 Spixxx

  • Members
  • PipPip
  • Member
  • 29 posts

Posted 19 March 2006 - 03:05 AM

Ok, here's the deal:

I have a dropdown that has the values No(selected) and Yes
I want to have an invisible dropdown that will show if the user selects Yes above, and dissapear if they change it back to know.

Things to know:

My form name is "file_editor"
My Yes/No dropdown name is "is_backup"
My function for this is called "showSelect"

Thanks for all help!!

#2 hitman6003

  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 19 March 2006 - 10:21 PM

Modify as needed:

    function showDiv(a) {
        if (a.selectedIndex == 0) {
            document.getElementById('hiddendiv').style.display = "none";
        } else {
            document.getElementById('hiddendiv').style.display = "block";

<select onchange="showDiv(this)" name="select1">
    <option selected value="y">Yes</option>
    <option value="n">No</option>

<div id="hiddendiv" style="display: none;">
<select name="select2" id="select2">
    <option selected value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users