Check af autogenereret form
Når man nu har en form der genereres således:For Each Key in shoppingcart
Id = Key
aParameters = GetItemParameters(Id)
Response.Write\"<tr>\"
Response.Write\"<td width=\'40%\'><!--mstheme--><font face=\'Verdana, Arial, Helvetica, Sans Serif\'><font size=\'1\'><a href=\'Beskr.asp?sider=ja&item=\"&Id&\"\' target=\'main\'>\"&aParameters(1)&\"</a></font><!--mstheme--></font></td>\"
Response.Write\"<td width=\'50%\'align=\'left\'><!--mstheme--><font face=\'Verdana, Arial, Helvetica, Sans Serif\'>\"
Response.Write\"<input type=\'text\' name=\'\"&Id&\"\' size=\'1\' style=\'font-size: 10px; border-style: solid; border-color: #C0C0C0\' value=\"&shoppingcart(Key)&\">\"
Response.Write\"<font size=\'1\'> x \" & FormatNumber(CDbl(aParameters(2)),2) & \"<!--mstheme--></font></td>\"
Response.Write\"<td width=\'10%\'><!--mstheme--><font face=\'Verdana, Arial, Helvetica, Sans Serif\'>\"
if Mid(Id,1,1) = \"U\" or Mid (Id,1,1) = \"S\" then
Response.Write\"<p align=\'center\'><a target=kurv href=\'Indkobskurven.asp?gebyr=\"&ned&\"&action=del&item=\" & Key & \"\'><img border=\'0\' src=\'fjern_fra_kurv.gif\' width=\'16\'height=\'15\'></a><!--mstheme--></font></td>\"
else
Response.Write\"<p align=\'center\'><a target=kurv href=\'Indkobskurven.asp?gebyr=0&action=del&item=\" & Key & \"\'><img border=\'0\' src=\'fjern_fra_kurv.gif\' width=\'16\'height=\'15\'></a><!--mstheme--></font></td>\"
end if
Response.Write\"</tr>\"
sTotal = sTotal + (shoppingcart(Key) * CDbl(aParameters(2)))
next
Hvordan skal følgende script så se ud:
<SCRIPT LANGUAGE=javascript>
function CheckForm()
{
if (isNaN(form1.??Id.value))
{
alert (\"Du kan kun indtaste tal!\")
??Id.focus();
return false;
}
if (form1.??Id.value == \'\')
{
alert (\"Du skal indtaste et tal!\")
??Id.focus();
return false;
}
if (form1.??Id.value > 10)
{
alert (\"Du har bestilt\"+form1.??Id.value+\"stk.\");
return true;
}
return true;
}
</SCRIPT>
Meningen er at scriptet skal checke om formen er ok