codingcodeddode
11-10-2012, 07:38 PM
Got it working
|
||||
Javascriptcodingcodeddode 11-10-2012, 07:38 PM Got it working Old Pedant 11-10-2012, 08:16 PM It doen't work because the method document.write( ) does *NOT* return any value. SO when you do var randomNumber = document.write(Math.floor((Math.random()*5)+4)); indeed that writes the number to the screen, but then it assigns the result of calling document.write( ) to your variable. But, as I said, that result is non-existent, so you are assigning null to your variable. It is also true that you shouldn't depend on being able to set the .value of a <select>. felgall 11-10-2012, 08:17 PM var randomNumber = Math.floor((Math.random()*5)+4); var runme = function(){ document.getElementById('selectBox').value = randomNumber; } and add id="selectBox" to the <select> Old Pedant 11-10-2012, 08:28 PM ???? His code says <select id='selectBox' name='selectBox'> codingcodeddode 11-10-2012, 08:31 PM the id is already there, still not sure whats wrong with my code :( codingcodeddode 11-10-2012, 08:34 PM i got it to work thanks |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum