Passing a value from a HTML button to another ASP page HELP!

D

djjohnst

I am creating a program that will list program times for people who
visit our website. Users can login create, edit, delete a program.
These dump into a database. The ASP webpage then reads from the
database and posts these programs for people to view (program type,
date, time, etc...). I am having trouble creating an edit option. When
bring up the edit page i want it to read the database and dynamically
create a table that has a button for each record in the recordset. I
want to be able to click that "edit" button and in a new window the
form appears filled out with the current record's information filled
in. However, to do this I am having trouble pulling out the button
name (which is the name of the DB primary key survey num) and passing
it to the other edit form. Some help me....PS i know the below code is
incorrect because it passes 28 which is the last record in the record
set, not the current. I know why it does this, I just do not know how
to fix it.


RSSQL = "Select * from Workshops where workshopdate > Date()"
rs.open RSSQL,conn,1,1

if rs.recordcount = 0 then
%> There are no upcoming workshops.
<%
response.end
end if

rs.movefirst

%>
<table width="499" border="1">
<tr>
<th width="139" scope="col"><div align="center">Date</th>
<th width="300" scope="col"><div align="center">Time</th>
<th width="300" scope="col"><div align="center">Location</th>
</tr>
<%

Do until rs.eof
WorkshopNum = rs("WorkshopNum")
WorkshopDate = rs ("WorkshopDate")
WorkshopStartTime = rs("WorkshopStartTime")
WorkshopEndTime = rs("WorkshopEndTime")
WorkshopLocation = rs("WorkshopLocation")

StartTime = Instr(WorkshopStartTime,":")
EndTime = Instr(WorkshopEndTime,":")
StartAMPM = right(WorkshopStartTime, 2)
EndAMPM=right(WorkshopEndTime, 2)

WorkshopStartTime=Left(WorkshopStartTime, StartTime+2)
WorkshopEndTime=Left(WorkshopEndTime, EndTime+2)

%>
<tr>
<td><div align="center"><%Response.write WorkshopDate%></td>
<td><div align="center"><%Response.write WorkshopStartTime &
StartAMPM & "-" & WorkshopEndTime& EndAMPM%></td>
<td><div align="center"><%Response.write WorkshopLocation%></td>
<td>
<input name="<%Response.Write WorkshopNum%>" type=Button onclick=
"window.open('editworkshop111.asp'); " value="Edit This Workshop"></
td>
</tr>
<%

session("workshopnum")= workshopnum

rs.movenext

loop

%>
 
A

Adrienne Boswell

I am creating a program that will list program times for people who
visit our website. Users can login create, edit, delete a program.
These dump into a database. The ASP webpage then reads from the
database and posts these programs for people to view (program type,
date, time, etc...). I am having trouble creating an edit option. When
bring up the edit page i want it to read the database and dynamically
create a table that has a button for each record in the recordset. I
want to be able to click that "edit" button and in a new window the
form appears filled out with the current record's information filled
in.

Does it have to open in a new window? What about people who hate windows
spawning, like me? Just an observation.
However, to do this I am having trouble pulling out the button
name (which is the name of the DB primary key survey num) and passing
it to the other edit form. Some help me....PS i know the below code is
incorrect because it passes 28 which is the last record in the record
set, not the current. I know why it does this, I just do not know how
to fix it.


RSSQL = "Select * from Workshops where workshopdate > Date()"

Please do not use * to select fields - name the fields individually.
rs.open RSSQL,conn,1,1

if rs.recordcount = 0 then
%> There are no upcoming workshops.
<%
response.end
end if

rs.movefirst

%>
<table width="499" border="1">
<tr>
<th width="139" scope="col"><div align="center">Date</th>
<th width="300" scope="col"><div align="center">Time</th>
<th width="300" scope="col"><div align="center">Location</th>
</tr>

<%

Do until rs.eof
WorkshopNum = rs("WorkshopNum")
WorkshopDate = rs ("WorkshopDate")
WorkshopStartTime = rs("WorkshopStartTime")
WorkshopEndTime = rs("WorkshopEndTime")
WorkshopLocation = rs("WorkshopLocation")

StartTime = Instr(WorkshopStartTime,":")
EndTime = Instr(WorkshopEndTime,":")
StartAMPM = right(WorkshopStartTime, 2)
EndAMPM=right(WorkshopEndTime, 2)

WorkshopStartTime=Left(WorkshopStartTime, StartTime+2)
WorkshopEndTime=Left(WorkshopEndTime, EndTime+2)

%>
<tr>
<td><div align="center"><%Response.write WorkshopDate%></td>
<td><div align="center"><%Response.write WorkshopStartTime &
StartAMPM & "-" & WorkshopEndTime& EndAMPM%></td>
<td><div align="center"><%Response.write WorkshopLocation%></td>
<td>
<input name="<%Response.Write WorkshopNum%>" type=Button onclick=
"window.open('editworkshop111.asp'); " value="Edit This Workshop"></
td>
</tr>

Where is workshopnum here? Oh - it's not, it's down below and changes as
it loops through. That won't work. You have to put the value somewhere
in an input element. Naming the input element is not going to work
either, because you would have to test for that name coming in from the
request.

What you need is something like name="field" value="<%=workshopnum%>", or
you would put it in a querystring, eg. "window.open('editworkshop111.asp?
<%

session("workshopnum")= workshopnum

rs.movenext

loop

%>

You might want to think about using getrows() as well.
 
D

djjohnst

Thanx for the response!!!

The thing is that it actually does pass the value of workshopnum to
the buttons! I just don't know how to pull that info out once it is
clicked. The reason i know it works is cause i'll changed

<input name="<%Response.Write WorkshopNum%>" type=Button onclick=
"window.open('editworkshop111.asp'); " value="Edit This Workshop">

to

<input name="<%Response.Write WorkshopNum%>" type=Button onclick=
"window.open('editworkshop111.asp'); " value="%Response.Write
WorkshopNum%">

and the buttons appeared 23, 24,25,26...etc.

I just want that number to go somewhere once it is clicked so I can
use that number.

Also I agree with the hating new windows poping up. I'll change that
but in the mean time I need to figure this first part out...Any other
advice!
 
E

Evertjan.

djjohnst wrote on 10 mei 2007 in microsoft.public.inetserver.asp.general:
<input name="<%Response.Write WorkshopNum%>" type=Button onclick=
"window.open('editworkshop111.asp'); " value="Edit This Workshop">

<input
type=Button
onclick="window.open('editw.asp?wNum=<%=WorkshopNum%>')"
value="Edit This Workshop">

and in the "editw.asp" file:

<% 'vbs
WorkshopNum = request.querystring("wNum")
%>
 
E

Evertjan.

djjohnst wrote on 10 mei 2007 in microsoft.public.inetserver.asp.general:
YES! that worked!! I want to give you a big kiss!!! Thank you so much!

Even so, it would be better if you quote what you are replying on,
since we then would know what you are talking about.

After all, this is usenet.
 
D

djjohnst

haha forgive me...

what worked was as follows:

<input name="<%Response.Write WorkshopNum%>" type=Button onclick=
"window.open('editWorkshop111.asp?wNum=<%=WorkshopNum%>')" value="Edit
This Workshop"></td>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top