ASP form not working

A

Athmaus

Hello,

I have this ecom page that i am making where customers can select to choose
additional licenses before they purchase. I have that part working with
javascript.

Problem is that when the selection is made and you hit the add but it isn't
sending to the right pages (and i think i need to do it in another statemen
instead of a if..then, since there will be at least 16 conditions here.

<%
Response.Expires = -1000
Response.Buffer = True

If Request.Form("purchase") ="true" Then
BuyCrossSale
Else
CrossSale
End If

Sub BuyCrossSale
Dim prod2, prod3, one, two, three, tons

one = "1"
two= "2"
three = "3"
tons = "99"

prod2 = Request.Form("prod2")
prod3 = Request.Form("prod3")

If Request.Form("licenses") = one AND prod2 = "on" AND prod3 = "on" Then
Response.Redirect "http://www.msn.com"
Else

If Request.Form("licenses") = one AND prod3 = "on" Then
Response.Redirect "http://www.dogpile.com"
Else

If Request.Form("licenses") = one AND prod2 = "on" Then
Response.Redirect "http://www.google.com"
Else

If Request.Form("licenses") = one Then
Response.Redirect "http://www.google.com"
Else

Response.Redirect "http://ps2.ign.com"

CrossSale
End If
End If
End If
End If
End Sub

%>



<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}

function UpdateTotal()
{

var product_name = "MAIN";
var regular = 0;
var saved = 0;
var total = 0;

var Ptotal = 0;
var Pregular = 0;

if(document.getElementById('frm').licenses.value == 1)
{
total += 19.99;
regular += 19.99 * 2;
}
else if(document.getElementById('frm').licenses.value == 2)
{
product_name = "MAIN x 2";
total += 29.99;
regular += 19.99 * 2 * 2;
}
else if(document.getElementById('frm').licenses.value == 3)
{
product_name = "MAIN x 3";
total += 39.99;
regular += 19.99 * 2 * 3;
}
else if(document.getElementById('frm').licenses.value == 99)
{
product_name = "MAIN Unlimited";
total += 69.99;
regular += 19.99 * 2 * 4;
}

Ptotal = total;
Pregular = regular;


if(document.getElementById('frm').prod2.checked)
{
document.getElementById("row_ap").style.display = '';
total += 9.99;
regular += 9.99;
}
else
{
document.getElementById("row_ap").style.display = 'none';
}

if(document.getElementById('frm').prod3.checked)
{
document.getElementById("row_aa").style.display = '';
total += 6.99;
regular += 39.99;
}
else
{
document.getElementById("row_aa").style.display = 'none';
}

saved = regular - total;


if(document.all) //ie
{
document.all("product_name").innerText = product_name;
document.all("product_price").innerHTML =
formatAsMoney(Ptotal).toString() + " <font size='1' color='#ffffff'
face='Verdana'><b>(<s>" + formatAsMoney(Pregular).toString() +
"</s>)</b></font>";

document.all("total_purchase").innerText = '$' +
formatAsMoney(total).toString();
}
else
{
document.getElementById("product_name").textContent = product_name;
document.getElementById("product_price").innerHTML =
formatAsMoney(Ptotal).toString() + " <font size='1' color='#ffffff'
face='Verdana'><b>(<s>" + formatAsMoney(Pregular).toString() +
"</s>)</b></font>";
document.getElementById("total_purchase").textContent = '$' +
formatAsMoney(total).toString();
}

return true;
}


function formatAsMoney(mnt)
{
mnt -= 0;
mnt = (Math.round(mnt*100))/100;
return (mnt == Math.floor(mnt)) ? mnt + '.00'
: ( (mnt*10 == Math.floor(mnt*10)) ?
mnt + '0' : mnt);
}

//-->
</script>
</head>


<body><% Sub CrossSale %>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th scope="col"> </th>
</tr>
<tr>
<td><table width="750" border="1" align="center" cellpadding="0"
cellspacing="0" bordercolor="#000000" class="bground">
<tr>
<th><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th> <form method="post" action="work.asp" target="_top"
name="frm" id="frm">
<input type="hidden" name="purchase" value="true">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="243" valign="top" align="center">
<table width="100%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td><table width="95%" border="0"
align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" class="product">Your
Current Order:</td>
</tr>
<tr>
<td><table width="95%" border="2"
align="center" cellpadding="1" cellspacing="2" bgcolor="#003364" class="para">
<!--DWLayoutTable-->
<tr>
<td width="113" align="left"
class="paraboldwhite" id="product_name">MAIN</td>
<td width="104" align="right"
class="paraboldwhite" id="product_price">19.99 <span
class="paraboldwhite2">(<s>39.99</s>)</span></td>
</tr>
<tr id="row_ap">
<td align="left"
class="paraboldwhite">PRODUCT 2 </td>
<td align="right"
class="paraboldwhite"><b>9.99 <span
class="paraboldwhite2">(<s>19.99</s>)</span></td>
</tr>
<tr id="row_aa">
<td align="left"
class="paraboldwhite">PRODUCT 3 </td>
<td align="right"
class="paraboldwhite">6.99 <span
class="paraboldwhite2">(<s>9.99</s>)</span></td>
</tr>
<tr>
<td style="padding:0px;" colspan="2"
valign="top"></td>
</tr>
<tr>
<td align="left"
class="paraboldred">Your Total:</td>
<td align="right"
class="paraboldred" id="total_purchase">$36.97</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></th>
<th width="457" valign="top"> <table width="100%"
border="0" cellpadding="0" cellspacing="0" id="AutoNumber2" class="para">
<tr>
<td colspan="2"><div align="center">
<select name="licenses" id="licenses"
onChange="return UpdateTotal();">
<option value="1">Single Computer
$19.99</option>
<option value="2">2 Computers $29.99</option>
<option value="3">3 Computers $39.99</option>
<option value="99">Unlimited Computer
License $69.99</option>
</select>
</div></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2" align="left" class="para"><br>
<input name="prod2" type="checkbox" id="prod2"
onClick="return UpdateTotal();" value="ON" checked="CHECKED" />
Yes, Include PRODUCT 2<br>
<input name="prod3" type="checkbox" id="prod3" onClick="return
UpdateTotal();" value="ON" checked="CHECKED" />
Yes, Include PRODUCT 3</td>
</tr>
<tr>
<td align="left" valign="top"> </td>
<td align="left" class="para"><br>
<br>
<a value="Add" name="yes" type="submit">
<input type="submit" value="Add" name="yes">
</a></td>
</tr>
</table>
</th>
</tr>
</table>
</form>
</th>
</tr>
<tr>
<td valign="top" align="center" class="footer"> </td>
</tr>
</table></th>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table><% End Sub %>

Any help is greatly appreciated :)
 
M

Mike Brind

Athmaus said:
Hello,

I have this ecom page that i am making where customers can select to choose
additional licenses before they purchase. I have that part working with
javascript.

Problem is that when the selection is made and you hit the add but it isn't
sending to the right pages (and i think i need to do it in another statemen
instead of a if..then, since there will be at least 16 conditions here.

<%
Response.Expires = -1000
Response.Buffer = True

If Request.Form("purchase") ="true" Then
BuyCrossSale
Else
CrossSale
End If

Sub BuyCrossSale
Dim prod2, prod3, one, two, three, tons

one = "1"
two= "2"
three = "3"
tons = "99"

prod2 = Request.Form("prod2")
prod3 = Request.Form("prod3")

If Request.Form("licenses") = one AND prod2 = "on" AND prod3 = "on" Then
Response.Redirect "http://www.msn.com"
Else

If Request.Form("licenses") = one AND prod3 = "on" Then
Response.Redirect "http://www.dogpile.com"
Else

If Request.Form("licenses") = one AND prod2 = "on" Then
Response.Redirect "http://www.google.com"
Else

If Request.Form("licenses") = one Then
Response.Redirect "http://www.google.com"
Else

Response.Redirect "http://ps2.ign.com"

CrossSale
End If
End If
End If
End If
End Sub

%>



<script language="JavaScript" type="text/JavaScript">

Any help is greatly appreciated :)

The (probable) reason that no one has so far responded to your post is
that you haven't really elucidated your problem. "It isn't sending to
the right pages" needs a bit more description, as does the purpose of
your code. It is unlikely that anyone is going to plough through all
the code you posted to try to establish your intended logic, especially
as it may be faulty.

Verify that the javascript is working correctly by using document.write
at key points to verify values, and that the values you are expecting
to be passed in the vbscript are really as they should be by using
response.write. You may find the root of the problem that way. If
not, get back to us with a bit more detail and a bit less (client side)
javascript.
 
A

Athmaus

yeah the javascript is 100% working and i got the aps works now as i replaced
the "on" with "true" I just wish i could streamline the code some more

tahnsk
 
E

Evertjan.

=?Utf-8?B?QXRobWF1cw==?= wrote on 03 sep 2006 in
microsoft.public.inetserver.asp.general:
the above is included in the below if clause,
because they both goto Google!

[please do not toppost on usenet]
yeah the javascript is 100% working and i got the aps works now as i
replaced the "on" with "true" I just wish i could streamline the code
some more

A lot of streamlining cn be done to the above:

vbs hase "elseif":

If Request.Form("licenses") = one AND prod2 = "true"_
AND prod3 = "true" Then
Response.Redirect "http://www.msn.com"
ElseIf Request.Form("licenses") = one AND prod3 = "true" Then
Response.Redirect "http://www.dogpile.com"
'''ElseIf Request.Form("licenses") = one AND prod2 = "true" Then
''' Response.Redirect "http://www.google.com"
ElseIf Request.Form("licenses") = one Then
Response.Redirect "http://www.google.com"
Else
Response.Redirect "http://ps2.ign.com"
CrossSale ' A line after a redirect is not executed!!!!!
End If

in short:

If Request.Form("licenses") = one AND prod2 = "true"_
AND prod3 = "true" Then
Response.Redirect "http://www.msn.com"
ElseIf Request.Form("licenses") = one AND prod3 = "true" Then
Response.Redirect "http://www.dogpile.com"
ElseIf Request.Form("licenses") = one Then
Response.Redirect "http://www.google.com"
Else
Response.Redirect "http://ps2.ign.com"
End If

however this perhaps is even simpler:

If Request.Form("licenses") <> one Then
Response.Redirect "http://ps2.ign.com"
ElseIf prod3 <> "true" Then
Response.Redirect "http://www.google.com"
ElseIf prod2 = "true" Then
Response.Redirect "http://www.msn.com"
Else
Response.Redirect "http://www.dogpile.com"
End If

Again, since after a redirect there is no execution,
you could use the ancient "If this Then that" syntax:

nolicence = (Request.Form("licenses") <> one)
If nolicence Then Response.Redirect "http://ps2.ign.com"
If prod3 <> "true" Then Response.Redirect "http://www.google.com"
If prod2 = "true" Then Response.Redirect "http://www.msn.com"
Response.Redirect "http://www.dogpile.com"

Enough steamlining logic?

Oh wait, perhaps you ment boolean True, not "true" as a string?:

licence = (Request.Form("licenses") = one)
If NOT licence Then Response.Redirect "http://ps2.ign.com"
If NOT prod3 Then Response.Redirect "http://www.google.com"
If prod2 Then Response.Redirect "http://www.msn.com"
Response.Redirect "http://www.dogpile.com"
 

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