leest Posted July 1, 2008 Share Posted July 1, 2008 Ok i am just after some advice, I have a registration form and want to make a a field only avaliable if the user selects yes from a drop down list. I also want to make this field a required field. I think i know how to achieve the last part but was just wondering if any body knew if having a form field display as a result of a drop down menu was possible. Link to comment https://forums.phpfreaks.com/topic/112797-if-else-based-on-a-drop-down-menu/ Share on other sites More sharing options...
LooieENG Posted July 1, 2008 Share Posted July 1, 2008 It would be best done with JavaScript Link to comment https://forums.phpfreaks.com/topic/112797-if-else-based-on-a-drop-down-menu/#findComment-579316 Share on other sites More sharing options...
lemmin Posted July 1, 2008 Share Posted July 1, 2008 Something like this: <form> <select onChange="if (this.value == 1) text1.style.visibility='visible'; else text1.style.visibility='hidden';"> <option value=0>No</option> <option value=1>Yes</option> </select> <input id="text1" type=TEXT name="text1" style="visibility:hidden"> </form> Link to comment https://forums.phpfreaks.com/topic/112797-if-else-based-on-a-drop-down-menu/#findComment-579321 Share on other sites More sharing options...
leest Posted July 6, 2008 Author Share Posted July 6, 2008 HI thanks for the reply and sorry in the delay but i have been away. Ok i am not to experienecd with javascript, the field that i want to make only visible if the value in the drop down list is the last field in my form, i have about ten form fields. so do i change the text1 to represent the field value. Cheers Link to comment https://forums.phpfreaks.com/topic/112797-if-else-based-on-a-drop-down-menu/#findComment-582932 Share on other sites More sharing options...
leest Posted July 6, 2008 Author Share Posted July 6, 2008 ok, i am a bit of an idiot and when i looked at it properly it made sense, the only thing is when i upload it to my server it didn't work, the drop down list worked but when i selected yes the other field didn't work. I know i have javascript running on my pc and so not sure why it would not work, could it be something on the server side??? Link to comment https://forums.phpfreaks.com/topic/112797-if-else-based-on-a-drop-down-menu/#findComment-582945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.