Jump to content

can this be done?


MildewMan1
 Share

Recommended Posts

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...