I'm new to JavaScript. I am trying to do some error checking on a page. The goal is when a user hits the submit key it checks for a certain option value. If that value is the default value it will alert the user to select another option.
The problem is i'm doing this on an asp file that was written about 5 or 6 six years ago and horribly coded. Basically I just want to know if my JavaScript is correct or not so I can determine where its breaking.
Here's the code:
- JavaScript -
<script type="text/javascript">
function focus()
{
document.Frontpage_Form1.operation_name.focus();
}
function checkSelect()
{
if (document.Frontpage_Form1.operation_name.value = "1")
{
alert("Please Select a Location / Operation type!");
document.Frontpage_Form1.operation_name.focus();return(false);
}
}
</script>
- HTML -
<form method="POST" action="parts_build.asp?part=<%=****_partnumber%>" name="FrontPage_Form1" onsubmit="return checkSelect(this)" language="JavaScript">
<select size="1" name="operation_name">
<option value="1">Please Select</option>
<%
Do Until RSLookUp5.EOF
%>
<option value="<%=RSLookUp5("shop_num")%>"><%=RSLookUp5("machine_location")%>
. . . <%=RSLookUp5("operation")%></option>
<%
RSLookUp5.MoveNext
Loop
%>
</select>
Thanks.
The problem is i'm doing this on an asp file that was written about 5 or 6 six years ago and horribly coded. Basically I just want to know if my JavaScript is correct or not so I can determine where its breaking.
Here's the code:
- JavaScript -
<script type="text/javascript">
function focus()
{
document.Frontpage_Form1.operation_name.focus();
}
function checkSelect()
{
if (document.Frontpage_Form1.operation_name.value = "1")
{
alert("Please Select a Location / Operation type!");
document.Frontpage_Form1.operation_name.focus();return(false);
}
}
</script>
- HTML -
<form method="POST" action="parts_build.asp?part=<%=****_partnumber%>" name="FrontPage_Form1" onsubmit="return checkSelect(this)" language="JavaScript">
<select size="1" name="operation_name">
<option value="1">Please Select</option>
<%
Do Until RSLookUp5.EOF
%>
<option value="<%=RSLookUp5("shop_num")%>"><%=RSLookUp5("machine_location")%>
. . . <%=RSLookUp5("operation")%></option>
<%
RSLookUp5.MoveNext
Loop
%>
</select>
Thanks.