javascript - one dropdown, 2 radios, 2 inputs -


ok, hard explain in native language try clear possible.

i have 1 dropdown different options. after choosing 1 of them, user need check 1 of 2 radio buttons give results in 2 different input fields. example - if choose option 2 dropdown, , check radio button 1, input 1 shows value , input 2 shows other value.

<select id="single">     <option>select item</option>     <option data1="140x200" data2="1">80x190</option>     <option data1="140x200/220" data2="2">80x200</option>     <option data1="140x220" data2="3">80x210</option> </select>  <input type="radio" id="radiobutton1" name="radiobutton" value="enkel" /> <label for="radiobutton1">enkel</label> <input type="radio" id="radiobutton2" name="radiobutton" value="dubbel" /> <label for="radiobutton2">dubbel</label> <input type="text" id="dekbed"> <input type="text" id="overtrek"> 

i have jsfiddle made, maybe helps clarification.

fiddle

maybe should give 4 attributes each option in dropdown (data1, data2, data3, data4), selected option gives data1 input #dekbed , data2 input #overtrek if radio1 checked, , data3 input #dekbed , data4 input #overtrek if radio 2 checked.

i hope guys understood this, , appreciate because still haven't seen way of selection before.

you can try adding condition check if each radio button checked inside of routine

 $("#single option:selected").each(function () { 

for example radiobutton1 be

   if ($("#radiobutton1").is(':checked')){  .... } 

if radiobutton1 checked, change values in dekbed , overtrek data1 , data 2.

otherwise if radiobutton2 checked

if ($("#radiobutton2").is(':checked')){  .... different} 

change values in dekbed , overtrek data3 , data 4.

edit note: need add these methods both change events of select box, , radio button inputs.

i created fiddle demonstrating solution at: jsfiddle.net/dbs2q/1/

i hope helps!


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -