Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

disable dropdown on form until data entered in field 1

Status
Not open for further replies.

pendle666

Technical User
Jan 30, 2003
295
GB
Hello

In my search form I have two textboxes and next to each is a dropdown for Exact Match or Like.

The dropdowns are disabled initially and the user needs to enter some data in the respective textbox to activate it.

I had some help on doing this back in October 08 and the code worked, but when I went back to the page recently to do some amendments, the dropdowns are permanently disabled, regardless of what text is entered in the textboxes. The code is pasted below - can anyone identify what has gone wrong?

Pendle

<table border ="1">
<tr>
<td>surname</td>
<td><input name="surname" id="surname" size="30" maxlength="50" onblur="this.parentNode.nextSibling.getElementsByTagName('select')[0].disabled=!(this.value.length)" /> </td>
<td>
<select name="surname" id="surname" disabled="true" >
<option value="=" selected>Exact Match</option>
<option value="like">Like</option>
</select>
</td>


</tr>
<td>name</td>
<td> <input name="name" id="name" size="30" maxlength="50" onblur="this.parentNode.nextSibling.getElementsByTagName('select')[0].disabled=!(this.value.length)" /> </td>
<td>
<select name="name" id="name" disabled="true">
<option value="=" selected>Exact Match</option>
<option value="like">Like</option>
</select>
</td>
</tr>

</table>
 
PS - I have just been advised that my problem is specific to Firefox as it works fine in Internet Explorer - is there anyone who can provide a fix to make it work in Firefox too?

Pendle
 
Id's should be unique. That means no two items cna have the same Id.

With that said, if you can change the id's for the drop downs, you can use a simpler way of modifying their disabled status that should work in both FF and IE, and most other browsers as well.


Code:
<table border ="1">
<tr>
<td>surname</td>
<td><input name="surname" id="surname" size="30"  maxlength="50" [red]onChange="document.getElementById('surname_dropdown').disabled=false;"[/red] />  </td>
<td>
    <select name="surname" id="[red]surname_dropdown[/red]" disabled="true" >
        <option value="=" selected>Exact Match</option>
        <option value="like">Like</option>
    </select>
</td>


</tr>
<td>name</td>
<td>    <input name="name" id="name" size="30"  maxlength="50" [red]onChange="document.getElementById('name_dropdown').disabled=false;"[/red]/>  </td>
<td>
    <select name="name" id="[red]name_dropdown[/red]" disabled="true">
        <option value="=" selected>Exact Match</option>
        <option value="like">Like</option>
    </select>
</td>
</tr>

</table>


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Hello

Thank you very much for that - it has worked for me on both Mozilla and IE.

thanks

Pendle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top