SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: disabling a textfield
-
Mar 23, 2005, 00:41 #1
- Join Date
- Jan 2005
- Location
- bahrain
- Posts
- 553
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
disabling a textfield
hi
i want to disable a textfield when a user selects a perticular value form select filed.
e.g i m having occupations in select field and when user selects 'others' the textfield should not be disable and disable for all other values.its urgent plzzz.....
regards
phphelp
-
Mar 23, 2005, 03:11 #2
That's a javascript issue (if you don't want to reload the whole page with PHP - then you can use the "READONLY" tag inside the <input> field) ... if my memory about javascript doesn't serve me wrong, you can do that with something like
Code:onclick="document.form.textbox.disabled=true"
-
Mar 23, 2005, 04:41 #3
- Join Date
- Oct 2004
- Location
- Asylum
- Posts
- 277
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
HTML Code:<form> <select name="occupation" onChange="toggleInput(this.options[this.selectedIndex].value, this.form.other_occupation)"> <option value="something">Something</option> <option value="other">Other</option> </select> Please specify: <input type="text" name="other_occupation"> </form> <script language="JavaScript"> function toggleInput(selected_value, input_box) { input_box.disabled = (selected_value != 'other'); input_box.readonly = (selected_value != 'other'); } </script>
Bookmarks