Jump to content

Work around needed for javascript disabled


murfitUK

Recommended Posts

I really know nothing about javascript. I've tried but just can't get the hang of it. The bit of code I'm using came from someone on this site - so I'm hoping I'll get some more help.Two drop-down select boxes. The first has magazine edition numbers 99,100,101,102 etc. The second has advert numbers from 1 to the max available for each issue. 99 might have 78 adverts, 100 might have 57 etc. Selecting the first part then enables the second drop-down box populated with the numbers 1 to whatever. The advert reference number therefore looks like 99/45 etc.

	   <select name="issue" id="issue" onchange='loadOptions(this.value)'>		   <option value="0" id='option0' selected> </option>		   <option value="97">97</option>		   <option value="98">98</option>		   <option value="99">99</option>		   <option value="100">100</option>		   <option value="101">101</option>		   <option value="102">102</option>	   </select>	   nbsp;/nbsp;		 <select name="num" id="num" disabled="disabled"></select>	   <script>		   myArray = [0, 71, 69, 67, 73, 68, 71];		   function loadOptions(x){			   var iss = document.getElementById('issue');			   if (iss.options[0].value == '0'){				   iss.remove(0);			   }			  			   var num = document.getElementById('num');			   num.options.length = 0;			  			   var opt;			   var len = myArray[x-96];			   for (var i = 1; i <= len; i++){				   opt = document.createElement('option');				   opt.value = i;				   opt.text = '' + i;				   try{					   num.add(opt, null);				   }				   catch (ex){					   num.add(opt);				   }			   }			   num.disabled = false;		   }		   </script>

If the user does not have javascript enabled then they can still select the issue number but the second drop-down list will not become enabled and will not populate with the required numbers 1 to whatever.I would like to insert something that checks if javascript is enabled. If not, I need a workaround. A simple textbox would do so that user could type in advert reference number (eg 101/34). Would rather this box not displayed unless absolutely essential as user could type in non-existent reference which I will then have to catch upon form submission.Thanks.

Link to comment
Share on other sites

Thanks. That was so easy and I am (almost) embarrassed at having asked!I've tested it now in FF and it works but I can't find out how to disabled js in IE7. No doubt it will be somewhere in a menu so obvious that its the last place I'll look!EDIT: Found out how to disable js in IE (google's great!) but its not obvious.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...