ASP Problems

They have: 426 posts

Joined: Feb 2005

I am having some problems with asp. At college and doing a lab in it....ahah...going mad i dont think the tutor knows what he is on about.

I cant get the value from the checkbox, when i post the form i get page cannot be found.

here is the form;

<%@ Language=VBScript %>
<HTML>
<HEAD>
<TITLE>add_sailor_request</TITLE>
</HEAD>
<BODY>
<h1>A form to get input</h1>
<h2>User entered data</h2>
<p>Enter the name for the new sailor to add:</p>
<p>
<FORM ACTION="add_sailor_response.asp" METHOD="post">
First Name: <INPUT TYPE="text" NAME="PeopleNameFirst"><br>
Last Name: <INPUT TYPE="text" NAME="PeopleNameLast"><br>
DOB: <INPUT TYPE="text" NAME="PeopleDOB"><br>
Class: <INPUT TYPE="text" NAME="PeopleProfessionalClass"><br>
Club: <INPUT TYPE="text" NAME="PeopleClubCode"><br>
Referee: <INPUT TYPE="checkbox" NAME="PRef" value="PeopleReferee" ><br>
State: <INPUT TYPE="text" NAME="PeopleState"><br>
View: <INPUT TYPE="text" NAME="PeopleView"><br>
<INPUT TYPE="submit">
</FORM>
</p>
</BODY>
</HTML>

(I just wrapped it in php tag so it shows up better than code tag)
Here is the ASP that captures the form the problem is in peopleReferee

<?php
<!--#include file=\"adovbs.inc\"-->
<%
 
Dim oRS
  Set oRS
=Server.CreateObject(\"ADODB.Recordset\")
  oRS.Open \"people\", \"dsn=20509703a\",adOpenKeyset,adLockOptimistic
  oRS.AddNew
  oRS.Fields(\"PeopleNameFirst\")=Request.Form(\"PeopleNameFirst\")
  oRS.Fields(\"PeopleNameLast\")=Request.Form(\"PeopleNameLast\")

oRS.Fields(\"PeopleReferee\")=if instr(\"PRef,\"PeopleReferee\") then Response.Write(\"checked\")

oRS.Fields(\"PeopleDOB\")=Request.Form(\"PeopleDOB\")
oRS.Fields(\"PeopleProfessionalClass\")=Request.Form(\"PeopleProfessionalClass\")
oRS.Fields(\"PeopleClubCode\")=Request.Form(\"PeopleClubCode\")
oRS.Fields(\"PeopleState\")=Request.Form(\"PeopleState\")
oRS.Fields(\"PeopleView\")=Request.Form(\"PeopleView\")
  oRS.Update

  Response.Write \"<p>A new sailor has been created \" _
    & \"using the following values:</p>\" _
    & \"<p>First Name: \" & oRS.Fields(\"PeopleNameFirst\") _
    & \"<br>Last Name: \" & oRS.Fields(\"PeopleNameLast\") _
    & \"<br>DOB: \" & oRS.Fieldes(\"PeopleDOB\") _
    & \"<br>Class: \" & oRS.Fieldes(\"PeopleProfessionalClass\") _
    & \"<br>Club: \" & oRS.Fieldes(\"PeopleClubCode\") _
    & \"<br>Referee: \" & oRS.Fieldes(\"PeopleReferee\") _
    & \"<br>State: \" & oRS.Fieldes(\"PeopleState\") _
    & \"<br>View: \" & oRS.Fieldes(\"PeopleView\") & \"</p>\"


  oRS.Close
?>

?>

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I don't believe that's correct syntax... try this:

if instr("PRef,"PeopleReferee") then
    oRS.Fields("PeopleReferee")=Response.Write("checked")
else
    oRS.Fields("PeopleReferee")=vbnull
end if
'

Mark Hensler
If there is no answer on Google, then there is no question.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.