MildewMan1 Posted April 29, 2007 Share Posted April 29, 2007 I've never used Javascript other than pre-made codes, so I was wondering if it's possible to edit this code so that when someone hits a reset button on the form, this code recognizes it and resets the variable SongLimit back to 0? <script type="text/javascript" language="javascript"> var SongLimit=0 var maxSongs=30 function setItems(item) { if(item.checked) {SongLimit=SongLimit+1} else {SongLimit=SongLimit-1} if (SongLimit>maxSongs) {item.checked=false SongLimit=SongLimit-1 alert('You may only choose '+maxSongs+' songs. If you have finished picking your '+maxSongs+' songs, you can press the submit to obtain your code. If you would like to start over, press the reset button at the top or bottom of the list and refresh the page. ') } } </script> Link to comment Share on other sites More sharing options...
jesh Posted May 1, 2007 Share Posted May 1, 2007 An easy way is like so: <input type="button" onclick="SongLimit = 0;" value="Reset Song Limit" /> Or, if you want to do more things when that button is clicked, you can create a function: function resetForm(){ SongLimit = 0; // other stuff...} And then call it like so: <input type="button" onclick="resetForm();" value="Reset Song Limit" /> Link to comment Share on other sites More sharing options...
MildewMan1 Posted May 2, 2007 Author Share Posted May 2, 2007 An easy way is like so:<input type="button" onclick="SongLimit = 0;" value="Reset Song Limit" /> Or, if you want to do more things when that button is clicked, you can create a function: function resetForm(){ SongLimit = 0; // other stuff...} And then call it like so: <input type="button" onclick="resetForm();" value="Reset Song Limit" /> hey thanks for the reply. I'll test that out.Edit: You're a God man heh. Thanks for putting the onClick idea into my head. Got exactly what I was looking for by using this code<input type=\"reset\" onClick=\"SongLimit = 0\" value=\"Reset\"/> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.