Reputation: 6328
This is in file: DrinkOrder.asp
<form action="DrinkResult.asp" method="post">
Drink:
<select name="drink">
<option>Coffee</option>
<option>Tea</option>
<option>Hot Chocolate</option>
</select>
<p/>
Sugar:
<input type="radio" name="sugar" value="1"> 1
<input type="radio" name="sugar" value="2"> 2
<input type="radio" name="sugar" value="3"> 3
<p/>
Milk: <input type="checkbox" name="milk">
<p/>
<input type="submit" value="Submit Order"><input type="reset" value="Reset">
</form>
This is in file: DrinkResult.asp
<%@language="Javascript"%>
<%
function milkOn(form){
var with = "";
if(form == "1") { with = "With milk"; }
else { with = "No milk"; }
return with;
}
%>
<%=("<table border=\"1\">")%>
<%=("<tr><th><i>Drink:</i></th>" + "<td> " + (Request.Form("drink")) + "</td>")%>
<%=("<tr><th><i>Sugar:</i></th>" + "<td> " + (Request.Form("sugar")) + "</td>")%>
<%=("<tr><th><i>Milk:</i></th>" + "<td>" + (milkOn(Request.Form("milk"))) + "</td>")%>
<%=("</table>")%>
After submitting form from DrinkOrder.asp to DrinkResult.asp, I received an error which clearly I don't know how to fix it.
After a few modification I made to detect the error location, I'm pretty sure it is located at milkOn(Request.Form("milk")) in file DrinkResult.asp because when I remove the statement, the result shows up.
What's wrong with my code here?
Upvotes: 0
Views: 244
Reputation: 1420
change
if(form == "1")
to
if(form == "on")
otherwise the code seems to test fine for me.
Upvotes: 1