troubleshooting Question

Don't fire onChange first time user selects an option

Avatar of saturation
saturation asked on
JavaScript
3 Comments1 Solution343 ViewsLast Modified:
I'm trying to prevent the alert box in OnChange from firing when the page loads and a user selects his or her first option.  After the first one selection, I do want the alert in the onChange to fire.  This code doesn't seem to be working.  Help?

<html>
<head>
<title></title>
<script language="javascript">
function save(i) {

      if (i != 0) {
      alert("****" + i);
      }
      i=1;
}
</script>
<BODY bgcolor=edede1 CLASS="MAINBODY" LINK=#003B72 VLINK=#003B72 TOPMARGIN=0 LEFTMARGIN=0">
<form name=form>
<select name="main" size="10" style="width:250px;" onchange="save(i);">
<option value=test></option>
<option value=test2></option>
</select>            
</form>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros