Ok a comple of things wrong...first off JS arrays typically start at 0.
You should pass objects to your function, not names, so you would
would want to pass this and you do not need to pass the form name.
Your field_text array needs to be initialized before hand too. I also
changed the array to an associative array moves faster and I think
looks nicer. Heres the reworked code:
<html>
<script>
function clearOnce2(theField) {
var field_text = new Array();
field_text["ncr_number"] = "enter ncr numbers, a, b,c";
field_text["part_num"] = "enter a part number";
field_text["order_num"] = "enter an order number";
if (theField.value == field_text[theField.name])
{theField.value="";}
}
// -->
</script>
<body>
<form name="imageupload"
action="file:///Macintosh%20HD/Users/joe/work/image%20app/image_app.cfm"
method="post" enctype="multipart/form-data">
<table border="3" style="font-weight:bold" align="center">
<tr align="center">
<td valign="middle"><span style="color:green">ncr number</span><br><br>
<span style="color:maroon; font-size:18">OR</span><br><br><span
style="color:orange">part number and order number</span></td>
<td valign="middle">
<input name="ncr_number" type="text" size="25" style="color:green"
maxlength="100" title="enter ncr numbers" VALUE="enter ncr numbers, a, b,c"
onfocus="javascript:clearOnce2(this);">
<br><br><span style="color:maroon; font-size:18">OR</span><br><br>
<input name="part_num" type="text" size="15" style="color:orange"
maxlength="25" title="part number" VALUE="enter a part number"
onfocus="javascript:clearOnce2(this);">
<input name="order_num" type="text" size="15" style="color:orange"
maxlength="25" title="order number" VALUE="enter an order number"
onfocus="javascript:clearOnce2(this);">
</td>
</tr>
</table>
<input type="submit" value="upload the image files">
</form>
</body>
</html>
Notice how instead of passing the name I just pass this...this refers
to the current object (in the cases above uit would the input box). If
for some reason you wanted access to the Form object you can do
this.form or in the function theField.form. If you need mroe
explaining let me know.
Adam
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:5:141886
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54