Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 29th, 2004, 01:41 AM
Authorized User
Join Date: Aug 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default conditional form submission

I have a form and its details need to be submitted to page1.asp if the user clicks on image1.gif and to page2.asp if the user click on image2.gif.

plz tell me how to do it.

I have tried to send the details via query string but getting errors.

my file name is product details.asp

<form name=addcart" action="productdetails.asp" method="post">
<tr><td class="bld">SIZE : <select name="psize" size="1" >
<option value="1">1</option>
<option value="2">2</option>
<tr><TD bgColor=#ffffff><IMG height=1 hspace=0 src="images/spacer.gif" width=1 border=0></TD></TR>
<tr><td class="bld">COLOR :<br>
<select name="pcolor" size="1">
<option value="red">red</option>
<option value="blue">blue</option>
<tr><TD bgColor=#ffffff><IMG height=1 hspace=0 src="images/spacer.gif" width=1 border=0></TD></TR>
<tr><td class="bld">QUANTITY :<br><select size="1" name="quantity">
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
              <option value="11">11</option>
              <option value="12">12</option>


dim psize
dim pcolor
dim quantity

        <tr><TD bgColor=#ffffff><IMG height=1 hspace=0 src="images/spacer.gif" width=1 border=0></TD></TR>
        <tr><td><a href="productdetails.asp?prodid=<%=trim(rs8.fields (0))%>&size=<% response.write psize%>&color=<%response.write color%>"><img src="images/add_cart.gif" border="0" height="23" width="116"></a></td></tr>
        <tr><TD bgColor=#ffffff><IMG height=5 hspace=0 src="images/spacer.gif" width=1 border="0"></TD></TR>

        <tr><td><img src="images/add_wishlist.gif" border="0" height="23" width="116"></td></tr>
        <tr><TD bgColor=#ffffff><IMG height=10 hspace=0 src="images/spacer.gif" width=1 border=0></TD></TR>

Old March 30th, 2004, 08:12 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

You can't do that with plain HTML.
You'll either have to create two separate forms, or you'll have to use some JavaScript like this (untested)"

<img src="img1.gif" onclick="document.forms[0].action='Page1.asp';document.forms[0].submit();" />
<img src="img2.gif" onclick="document.forms[0].action='Page2.asp';document.forms[0].submit();" />

With this code, the action attribute of the form is changed dynamically, and then the form is submitted.

Does this help?


Imar Spaanjaars
Everyone is unique, except for me.

Similar Threads
Thread Thread Starter Forum Replies Last Post
form submission...help!? mdbrueckner ASP.NET 2.0 Basics 1 September 19th, 2007 06:16 PM
C# reset of checkbox after form submission booksnore2 General .NET 5 July 29th, 2004 10:30 AM
Simple Form Submission Maxood Beginning PHP 3 July 17th, 2004 06:03 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.