Solved

I have 2 submit buttons  where I added code for each buttons click event to change the action page to different pages, I am getting Jva script error and Pages are not redirecting

Posted on 2003-11-13
4
403 Views
Last Modified: 2010-04-09
I have 2 submit buttons  where I added code for each buttons click event to change the action page to different pages, I am getting Jva script error and Pages are not redirecting when I click on the
Below is the ASp page I am attaching, Please tell me Where I am doing wrong
Please........

<%@ Language=VBScript %>
<%Option Explicit%>

<%'Author: Selina Chang
  'Date: August 7, 2000
  'Page: approveuser.asp
  'Purpose: Shows a list of users that need to be approved. Admin can select users that are
  '                  waiting to be approved.      
  Dim sButton            
%>


<% If Session("AdminID") = "" Then

Response.Redirect "adminlogin.asp"

Else %>
<!-- #include file="toptemp2.asp" -->
<% End if %>
                  
<TR>
<TD colspan=7 nowrap>
<P><FONT COLOR="red">Please check the box next to the Person ID to approve an User.<BR>
Click the Approve button at the end of the table after your selections</FONT></P>
<TABLE BORDER=1 WIDTH="100%" align=Center>
<TR>                              <!-- setting up the table for search results-->

<TD nowrap>
<CENTER><P><FONT FACE="Comic Sans MS" SIZE=+1>Approve</FONT></p></CENTER>
</TD>

<TD nowrap>
<CENTER><P><FONT FACE="Comic Sans MS" SIZE=+1>Person ID</FONT></p></CENTER>
</TD>
                                                            
<TD nowrap>
<CENTER><P><FONT FACE="Comic Sans MS" SIZE=+1>First Name</FONT></p></CENTER>
</TD>

<TD nowrap>
<CENTER><P><FONT FACE="Comic Sans MS" SIZE=+1>Last Name</FONT></p></CENTER>
</TD>

<TD nowrap>
<CENTER><P><FONT FACE="Comic Sans MS" SIZE=+1>User ID</FONT></p></CENTER>
</TD>

<TD nowrap>
<CENTER><P><FONT FACE="Comic Sans MS" SIZE=+1>Password</FONT></p></CENTER>
</TD>

<TD nowrap>
<CENTER><P><FONT FACE="Comic Sans MS" SIZE=+1>Phone</FONT></p></CENTER>
</TD>

</TR>

<%
Response.Write "<FONT FACE=Comic Sans MS>"

Dim intCount                                                            'Keeps the number of records found
Dim strConn                                                                  'set up the connection string
Dim objRec                                                                        'Open a recordset object
Dim strSQL

Catalog=prodemkt;Data Source=foxhound.nigas.com,2025;" %>
<!-- #include file="DataConn.asp" -->

<%

strSQL = "SELECT PersonID, FirstName, LastName, UserID, Password,Phone, Approved"
strSQL = strSQL + " FROM Person WHERE Approved = 0"
strSQL = strSQL + " ORDER BY PersonID;"

Set objRec=Server.CreateObject ("ADODB.Recordset")
objRec.Open strSQL, strConn

'Select records in the data base that match the query under the category, short_description,
'and long_descrption columns
'objRec.Filter = "Category Like '*" & Request.Form("keywords") & "*' OR ItemName Like '*" & Request.Form("keywords") & "*' OR ShortDescription Like '*" & Request.Form("keywords") & "*' OR LongDescription Like '*" & Request.Form("keywords") & "*'"

intCount=0
'Response.Write "<FORM METHOD='POST' Action ='approveuser2.asp' id=form1 name=form1>"
Response.Write "<FORM id=form1 name=form1 Method = 'Post'>"
While Not objRec.EOF

If Not objRec("Approved") Then
intCount=intCount+1

Response.Write "<TR>"

Response.Write "<TD align='center'>"
Response.Write "<INPUT TYPE='checkbox' NAME='Approved' VALUE='" & objRec("PersonID")& "'>"
Response.Write "&nbsp;</TD>"

Response.Write "<TD align='center'>"
Response.Write objRec("PersonID")
Response.Write "&nbsp;</TD>"

Response.Write "<TD>"
Response.Write objRec("FirstName")
Response.Write "&nbsp;</TD>"

Response.Write "<TD>"
Response.Write objRec("LastName")
Response.Write "&nbsp;</TD>"

Response.Write "<TD>"
Response.Write objRec("UserID")
Response.Write "&nbsp;</TD>"

Response.Write "<TD>"
Response.Write objRec("Password")
Response.Write "</TD>"

Response.Write "<TD nowrap>"
Response.Write objRec("Phone")
Response.Write "&nbsp;</TD>"


End if
objRec.MoveNext

Wend

If intCount=0 then
Response.Write "<TR Colspan=8> <TD colspan=7> Sorry, no New User found... </TD></TR>"
end If

Response.Write "<TR><TD COLSPAN=8><INPUT TYPE='Submit' NAME='btnApprove' VALUE='Approve' onclick='action='approveuser2.asp';'>&nbsp;<INPUT TYPE='Submit' NAME='btnDelete' VALUE='Delete' onclick='action='approveform.asp';'>&nbsp;<INPUT TYPE='Reset'></TD></TR>"
Response.Write "</FORM>"
Response.Write "</FONT>"

objRec.Close
set objRec = Nothing


 %>
 </Table>
 <P>&nbsp;</P>
 </TD></TR>
 

<!-- #include file="bottomtemp.asp"-->

0
Comment
Question by:suruku
  • 3
4 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 9741740
Response.Write "<TR><TD COLSPAN=8><INPUT TYPE='submit' NAME='btnApprove' VALUE='Approve' onclick=""this.form.action='approveuser2.asp';"" />&nbsp;<INPUT TYPE='submit' NAME='btnDelete' VALUE='Delete' onclick=""this.form.action='approveform.asp';"">&nbsp;<INPUT TYPE='Reset'></TD></TR>"
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9741762
use double double-quotes "" to produce one double-quote in the HTML.  Essentially, this is what I changed:

onclick=""this.form.action='approveuser2.asp';""

onclick=""this.form.action='approveform.asp';""
0
 

Author Comment

by:suruku
ID: 9741862
knightEknight
What should I put in Form Action value in the form tag And should I include Method = post

Please advice
Response.Write "<FORM id=form1 name=form1 Method = 'Post'>"
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 140 total points
ID: 9741992
You can put in a default action, and I would recommend quoting all the attributes:

Response.Write "<FORM id='form1' name='form1' Method='Post' action='approveform.asp' >" 
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Scrolling the scrollbar in a list in html 9 49
Javascript create file issue 4 48
Form not operating correctly. 1 23
Form Processing in PHP 11 32
This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now