drop down options depending on the selected radio button in javascript -


I have two radio buttons: in-campus and off-campus. When selected at the campus, the dropdown will have some options and when the off-campus is selected, there will be a separate set of options. How can I do this in JavaScript?


I'm trying to use it. I have this code

  set the set Incamus (A) {if (A == "true") {setOptions (document.form.nature.options [document.form.nature.selectedIndex] .value)}} function set option (selected) {// stuff}  

This will not work What is wrong?

  & lt; Html & gt; & Lt; Top & gt; & Lt; Script language = "javascript" & gt; Var current = false; Function on change () {var rad = document.getElementById ("radIn"). Checked; Return (if rad == current); Current = rad; Var array = rad? ["In1", "in2", "in3", "in4", "in5"]: ["out1", "out2", "out3", "out4", "out5"]; Var sel = document.getElementById ("dropdown"); Sel.innerHTML = ""; Var choose; For each array (in var k) {// alert (k + "asdsd"); Opt = document.createElement ("Options"); Opt.innerHTML = k; Sel.appendChild (optional); }} & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body Onload = "On Change ();" & Gt; & Lt; Input type = "radio" value = "in" name = "premises" onclick = "onChange ()" id = "radIn" check = "true" /> & lt; Label = "radIn" & gt; In campus & lt; / Label & gt; & Lt; Br / & gt; & Lt; Input type = "radio" value = "out" name = "premises" onclick = "onChange ()" id = "radOut" /> & Lt; Label = "radOut" & gt; Out campus & lt; / Label & gt; & Lt; Br / & gt; & Lt; Select ID = "Drop Down" /> & Lt; / Body & gt; & Lt; / Html & gt;  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -