play_ Posted April 1, 2006 Share Posted April 1, 2006 I made a function that, calls another function after 1milisecond (its being used on a submit button, so when the button is pressed, it disables).Anywyas, if i use this format, it works:[code] function disable(id) { var obj = document.getElementById(id); obj.value='Loading. . .'; obj.disabled=true; } function dis() { setTimeout('disable(1)', 1000) }[/code]and the button:<input type="submit" name="submit" value="Add this shirt" onmouseover="dis(1)" id="1" />However, this is no good because on the 'dis' function, i hand-coded the '1' in there.So ive been trying to pass a paremeter to dis(), and use that paremeter on:setTimeout('disable(1)', 1000) <--- 1 here would be the paremeter passed.So i tried this:[code] function disable(id) { var obj = document.getElementById(id); obj.value='Loading. . .'; obj.disabled=true; } function dis(num) { setTimeout('disable(num)', 1000) }[/code]That way, dis() would call disable() with the paremeter of 1.However, it keeps saying 'num' is not defined.Any ideas? Quote Link to comment Share on other sites More sharing options...
play_ Posted April 1, 2006 Author Share Posted April 1, 2006 Edit. Found a solution. i had to type cast the paremeter.in case anyone plan on using this script, here is the correct form:[code] function disable(id) { var obj = document.getElementById(id); obj.value='Loading. . .'; obj.disabled=true; } function dis(num) { id = Number(num) setTimeout('disable(id)', 1) }[/code]enjoy Quote Link to comment Share on other sites More sharing options...
emehrkay Posted April 2, 2006 Share Posted April 2, 2006 if you're worried about validation, id change that id from a 1 to somethign that at least starts wilth a letterand on the button you could have said 'this' instead of passing the id in Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.