By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,644 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,644 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

%>

May 10 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Gazing into my crystal ball I observed djjohnst <dj******@gmail.com>
writing in news:11**********************@l77g2000hsb.googlegr oups.com:
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>
No need for <div align="center"on a th element. It natively does that.
Better to get rid of presentational markup and use CSS.
><%

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?
field=<%=workshopnum%>');" Then you can get the value from
reques.querystring.
><%

session("workshopnum")= workshopnum

rs.movenext

loop

%>

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

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

May 10 '07 #2

P: n/a
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!

May 10 '07 #3

P: n/a
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=<%=WorkshopNu m%>')"
value="Edit This Workshop">

and in the "editw.asp" file:

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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 10 '07 #4

P: n/a
YES! that worked!! I want to give you a big kiss!!! Thank you so much!

May 10 '07 #5

P: n/a
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 11 '07 #6

P: n/a
haha forgive me...

what worked was as follows:

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

May 14 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.