javascript - Display form field based on selection -


I need to create a form that can choose another selection, when some can be selected, For example, if I select the gender: male, the input form displays "blue", and when the gender: female input form displays "pink".

I assume that Javascript / jQuery will be the best bet?

This is what I am far away from:

  ceremony showHideSchools (obj) {// Here we get the value of the selected object var cursel = obj.options [ Obj.selectedIndex] .value // if A, B, or no other option, hide more Divi Switch (Coral) {case '0-2': document.getElementById ('schools'). Style.display = "none" break; Case '3-5': document.getElementById ('school'). Style.display = "block" break; Case '9-11': document.getElementById ('school'). Style.display = "block" break; Case '12 -14 ': document.getElementById (' school '). Style Disconnect = "block" break; Case '15 -16': document.getElementById ('school'). Style Disconnect = "block" break; Case '17-18': document.getElementById ('schools'). Style.display = "block" break; Case '19 more ': document.getElementById (' schools'). Style.display = "block" break; Default: document.getElementById ('school'). Style.display = "none"}}  

to get the value of your selection box For jquery like:

  $ ('# selectList'). Val ();  

See full examples:

According to this value

Change the value of the form input

< Pre> $ ('# inputElem') Val (myval).

Comments