jrolinson
Joined: 24 Mar 2008 Posts: 1
|
Posted: Mon Mar 24, 2008 12:07 pm Post subject: What's wrong with this script? |
|
|
Trying to get some script working that simply gets user input, checks if that input string has already been used and either tells the user or continues. For now, the script has a fair few test window alerts, but I can't see why it's not working. Can anyone help?
<html>
<head>
<script language="JavaScript">
function MakeNewClient()
{
window.alert("test1");
NewClientName = window.prompt("Please enter client name","");
NameExists = false;
if ((NewClientName != null) && (NewClientName != ""))
{
for (count = 0; count < document.forms[0].AdminClient.length; count++)
{
If (document.forms[0].AdminClient.options[count].text == NewClientName)
{
NameExists = true;
}
window.alert(document.forms[0].AdminClient.options[count].text);
}
If (NameExists == true)
{
window.alert("That client name already exists. Please choose another.");
}
else
{
window.alert("TEMP continue with new client creation");
}
window.alert("test2");
}
window.alert("test3");
}
</script>
</head>
<body>
<form>
<P>
<Select Name="AdminClient">
<OPTION>Client 1
<OPTION>Client 2
<OPTION>Client 3
</SELECT></P>
<input name = btn type=button value="Some text" onClick="MakeNewClient()">
</form>
</body>
</html> |
|