Response.write if statements in a form? (1 Viewer)

natalie_2008

New member
Local time
Today, 23:51
Joined
Apr 30, 2008
Messages
1
Hope this is the correct thread to post in.
I am a student and currently studying sql, vbscript and web based databases etc.
However i am pretty much stuck on the following piece of script.

<%
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "pqrtrav"
Set Rs=MyConn.Execute("SELECT*From[trip]Order by activity")
Previousactivity="None"
WHILE NOT Rs.EOF

CurrentActivity=Rs("Activity")

if (CurrentActivity<>PreviousActivity) then
%>
<%Response.Write(Rs("Activity")) %> <input name="<%Response.Write(Rs("Activity")) %>" type="checkbox" value="<% Response.Write(Rs("Activity")) %>" >
<%
end if
PreviousActivity=CurrentActivity

Rs.MoveNext

WEND
Rs.Close

MyConn.Close
%>

I have opened the database and produced a list of 'activities' taken from the database with a checkbox along side it. However, when I submit the form, the information is not displayed on the next page when boxes are checked. On the submit page, i have the following code, <% Response.write (Request.Form("")) %> but do not know what to put in between the speech marks as i cannot specify the value if it taken from a list.
How would it be possible to display this information on the submit page after a box has been checked??

Please help,
kind regards Natalie
 

dan-cat

Registered User.
Local time
Today, 23:51
Joined
Jun 2, 2002
Messages
3,433
Hope this is the correct thread to post in.
I am a student and currently studying sql, vbscript and web based databases etc.
However i am pretty much stuck on the following piece of script.

<%
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "pqrtrav"
Set Rs=MyConn.Execute("SELECT*From[trip]Order by activity")
Previousactivity="None"
WHILE NOT Rs.EOF

CurrentActivity=Rs("Activity")

if (CurrentActivity<>PreviousActivity) then
%>
<%Response.Write(Rs("Activity")) %> <input name="<%Response.Write(Rs("Activity")) %>" type="checkbox" value="<% Response.Write(Rs("Activity")) %>" >
<%
end if
PreviousActivity=CurrentActivity

Rs.MoveNext

WEND
Rs.Close

MyConn.Close
%>

I have opened the database and produced a list of 'activities' taken from the database with a checkbox along side it. However, when I submit the form, the information is not displayed on the next page when boxes are checked. On the submit page, i have the following code, <% Response.write (Request.Form("")) %> but do not know what to put in between the speech marks as i cannot specify the value if it taken from a list.
How would it be possible to display this information on the submit page after a box has been checked??

Please help,
kind regards Natalie

You need to supply the name of the checkbox that you have populated with your Rs("Activity") value.

Thus if your original checkbox renders like so:

Code:
<input name="act001" type="checkbox" value="myValue" />

You retrieve the value of that checkbox via it's 'name' attribute:

Code:
request.form("act001")

Be aware that no value will be posted to the receiving form if the checkbox is unticked.
 

Users who are viewing this thread

Top Bottom