Hi everyone,
I am new to JavaScript and have run into a small problem.
My code works perfectly inside DreamWeaver but is crazy in both IE8 and FireFox.
In FireFox, I cannot insert text in the text fields.
In IE8, I can insert text, but nothing else happens.
My code is as follows:
[CODE] <script language=”JavaScript”>
<!–
var Counter;
function initForm()
{
Count = 0; // starts the count at 0
document.form1.timeEvents.value = Count; // displays the count
}
function increaseCount()
{
Count ++; // increases the count by 1 each time it is used
document.form1.timeEvents.value = Count; // displayes the new count
}
function clicked(fieldName)
{
increaseCount(); // calls increaseCount function
alert(fieldName + ” was clicked. Event Count = ” + Count + “.”); // sends alert and displays new count when event is triggered
}
function change(fieldName)
{
increaseCount(); // calls increaseCount function
alert(fieldName + ” was changed. Event Count = ” + Count + “.”); // sends alert and displays new count when event is triggered
}
function withfocus(fieldName)
{
increaseCount(); // calls increaseCount function
alert(fieldName + ” is focused. Event Count = ” + Count + “.”); // sends alert and displays new count when event is triggered
}
//–>
</script>
[CODE]
<form id=”form1″ name=”form1″ method=”post” action=””>
<label>First Name
<input name=”FirstName” type=”text” onClick=”clicked(document.form1.FirstName.name);” // calls clicked function when FirstName field is clicked
onChange =”change(document.form1.FirstName.name);” // uses the change fuction when FirstName field has been altered
onFocus =”withfocus(document.form1.FirstName.name);” // When FirstName has focus, calls the withfocus function
/>
</label>
<br />
<label>
Last Name</label>
<label>
<input name=”LastName “type=”text” id=”LastName” onClick=”clicked(document.form1.LastName.name);” // calls clicked function when LastName filed is clicked
onChange =”change(document.form1.LastName.name);” //calls change function when LastName field detects a change
onFocus =”withfocus(document.form1.LastName.name);” // when focus is on LastName field, calls withfocus function
/>
</label>
<br />
<label>Phone Number
<input name=”Phone” type=”text” id=”Phone” onClick=”clicked(document.form1.Phone.name);” // calls the click function when phone field has been clicked
onChange =”change(document.form1.Phone.name);” // calls the change function when a change occurs in the phone field
onFocus =”withfocus(document.form1.Phone.name);” // calls the withfocus function when focus is on the phone filed
/>
</label>
<br />
Number of times event(s) was triggered
<input type=”text” name=”timeEvents” />
Any suggestions would be greatly appreciated