We help IT Professionals succeed at work.

Write out the value of a drop down box posted from a another pages XSL form using ASP

Biggsy
Biggsy asked
on
Hi everybody,

I have an ASP page which is trying to request the contents of a drop down box from another page.

This value will then be added to the 'subject' field of an email that I'll be sending out.

However, this 'subject' field has remained blank suggesting that either it can't find a), the form or b), my particular drop-down value.

The look and feel of the drop down box is stored in a file called email.xsl. This then posts to email.asp. How can I pick up the contents of this "sport" drop down box on the email.asp page????

Thanks

The email.asp page is shown below.

START
=====

<%@ LANGUAGE="VBSCRIPT" %>
<%

option explicit
on error resume next
     
dim strSubj
dim oEmail
         
strSubj = Request.Form("sport") 'THIS IS THE IMPORTANT BIT!
                   
set oEmail = server.createobject("SessionObjects.Email")
oEmail.Send "email@email.com", "email@email.com", strSubj, "some words for the body of the text", "text","", "email@email.com"

set oEmail = nothing

on error goto 0
       
%>

END
===

oEmail.send sends an email from email@email.com to "email@email.com. strSubj is the subject of the email, (I want this to display the chosen value of the drop-down box). There will be some hardcoded words that go into the body of the text and the reply to address is email@email.com.


The email.XSL page is shown below. NB I have cut a lot of the coding out to show you the basics.

<!DOCTYPE xsl:stylesheet [
 <!ENTITY nbsp " ">
]>

<SCRIPT LANGUAGE="JAVASCRIPT" >
<xsl:comment><![CDATA[

function checkinput(bvalue)
{
 var d=document.forms['Recalc'];
 document.forms['Recalc'].action = "https://secure.????.com/email.asp?Action=Purchase";
 document.forms['Recalc'].submit();
}
function SUBMIT(bvalue,ButtonName)
{
 document.forms['Recalc'].Split.value =[bvalue];
 document.forms['Recalc'].action = "https://secure.????.com/email.asp?Action=" + ButtonName;
 document.forms['Recalc'].submit();
}

]]> </xsl:comment>
</SCRIPT>

<body>
<FORM action="" method="post" name="Recalc" > 
     <input type="hidden" name="Split"/>
</FORM>
</body>

</xsl:template>
<xsl:template match="sport">

<!-- IMPORTANT BIT. IT'S ONE OF THESE CHOSEN VALUES THAT I WANT TO ADD TO THE 'SUBJECT' FIELD OF MY EMAIL -->

<table><tr><td colspan="3" height="30" width="510">
<select name="sport" size="1">
<option selected="selected">Please Select -></option>
<option value="football">football</option>
<option value="cricket">cricket</option>
<option value="hockey">hockey</option>
<option value="other">other</option>
</select>
</td></tr></table>

<img name="Purchase" src="Purchase.gif" value="Purchase" />

</xsl:template>
</xsl:stylesheet>
Comment
Watch Question

Commented:
What's the resulting HTML from email.xsl?

I can't see how the form is submitted (probably, you cut out that portion when posting it), and the template "sport" probably nowhere gets called. You would call/include it by:

<FORM action="" method="post" name="Recalc" > 
    <input type="hidden" name="Split"/>
    <xsl:call-template name="sport"/>
</FORM>

Author

Commented:
Robbert,

The form is successfully being submitted as there is some JavaScript validation, (which I did omit) that checks that the drop-down box has been clicked i.e. the person can't leave it simply saying 'Please Select'. Therefore this would suggest that the form is being called.

The file email.xsl is actually a lot, lot longer as it also does credit card checking. I have tried substituting Request.Form("sport") for Request.Form("card_name") in email.asp but this doesn't seem to be picked up either, and the credit card info. is definitely being submitted in the form otherwise customers wouldn't be able to check out.

I still think that it's the coding in email.asp which isn't working, or maybe the contents of the form aren't being stored in the HTTP header???

Commented:
There are many variables which I don't know... Can you post the complete HTML source that is generated from email.xsl?

Author

Commented:
Hi Robbert,

Here is the complete HTML file. Thanks.

###########

<head>
<title>Checkout</title>
<SCRIPT LANGUAGE="JAVASCRIPT" xmlns:z="#RowsetSchema"><!--

function IsValidNumber(vNumber)
{
   
    var Valid = "True";
    var VALID_NUMERIC_VALUES
    VALID_NUMERIC_VALUES = "0123456789";


    if (vNumber.length == 0 )
      Valid = "False";  
    else
      {
         for(var i=0;i<vNumber.length;i++)
           {
 
            if ((VALID_NUMERIC_VALUES.indexOf(vNumber.substr(i,1))) == -1)
              Valid = "False";      
           }
      }
return Valid;
}  

function AddErrorMessage(vsErrorMessage,aErrorMessages)
{
var arraylength  
arraylength=aErrorMessages.length;
aErrorMessages[arraylength]= vsErrorMessage;
}

function CheckBlankInput(vsInput,vsErrorMessage,aErrorMessages)
{
if (vsInput == "")
 {
   if (vsErrorMessage != "")
   AddErrorMessage(vsErrorMessage,aErrorMessages);
 }    

}


function checkinput(bvalue)
{
 var d=document.forms['Recalc'];
 var aErrorMessages=new Array()
 var startdate
 var expirydate
 var Displaymessage


expirydate=d.CardExpiryMonth.options[d.CardExpiryMonth.selectedIndex].text+d.CardExpiryYear.options[d.CardExpiryYear.selectedIndex].text;
startdate=d.CardValidMonth.options[d.CardValidMonth.selectedIndex].text+d.CardValidYear.options[d.CardValidYear.selectedIndex].text;
if ((IsValidNumber(startdate)) != "True")
startdate="";
if ((IsValidNumber(expirydate)) != "True")
expirydate="";
CheckBlankInput(expirydate, "* Credit Card expiry date", aErrorMessages);

if (d.card_name.value.length < 3)
      AddErrorMessage("* Credit Card Holder Name",aErrorMessages);
      
if (d.sport.value.length < 3)
      AddErrorMessage("* What sport you play",aErrorMessages);

d.card_start.value = startdate;
d.card_exp.value = expirydate;

if ((IsValidNumber(document.forms['Recalc'].card_no.value)) != "True")
 d.card_no.value="";
CheckBlankInput(d.card_no.value,"* Credit Card Number", aErrorMessages)

if (aErrorMessages.length >0)
{
 
       var Displaymessage="";      

      for(var i=0;i<aErrorMessages.length;i++)
                Displaymessage += aErrorMessages[i]+ "\n";

      Displaymessage += "\n ... missing or invalid! \n"
         alert(Displaymessage);
 }
 else
 {
 document.forms['Recalc'].Split.value =[bvalue];
 pleasewait();
 }
}
function pleasewait() {
      
      if(navigator.appName != "Netscape") {
                  document.all.item("processing").style.visibility="visible";
                  document.all.item("processing").style.top="20";
                  document.all.item("processing").style.left="32";
                  document.all.item("mainform").style.visibility="hidden";
                  window.scroll(0,0);
      }

// This needs to be replaced by a parameterised call to get the correct type of URL.
      document.forms['Recalc'].action = "https://secure.????.com/store/email.asp?Action=Purchase";
//      document.forms['Recalc'].action = "email.asp?Action=Purchase";
      document.forms['Recalc'].submit();
}
function SUBMIT(bvalue,ButtonName)
{
    document.forms['Recalc'].Split.value =[bvalue];
// This needs to be replaced by a parameterised call to get the correct type of URL.
      document.forms['Recalc'].action = "https://secure.????.com/store/email.asp?Action=" + ButtonName;
//      document.forms['Recalc'].action = "email.asp?Action=" + ButtonName;
      document.forms['Recalc'].submit();

      
}
function DefaultHarlequin()
{
      document.forms['Recalc'].Paper(0).checked = true;
}

function HideRadio()
{
      document.forms['Recalc'].Paper(0).checked = false;
      document.forms['Recalc'].Paper(1).checked = false;
      document.forms['Recalc'].Paper(2).checked = false;
      document.forms['Recalc'].Paper(3).checked = false;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

--></SCRIPT><link rel="stylesheet" HREF="/library/styles/Style.css" type="text/css" xmlns:z="#RowsetSchema">
<link rel="stylesheet" HREF="/library/styles/Style.css" type="text/css" xmlns:z="#RowsetSchema">
</head>

<body background="/images/bgLgtOrge.gif" style="MARGIN-LEFT: 17px; MARGIN-TOP: 5px" onload="" xmlns:z="#RowsetSchema">
<table border="0" cellpadding="0" cellspacing="0" width="540">
<tr>
<td colspan="3"><img src="/images/spacer.gif" width="1" height="3" border="0"></td>
</tr>
<tr>
<td width="80" valign="top" align="left"><img src="/images/spacer.gif" width="3" height="1" border="0"><a href="javascript:history.back();"><img src="/images/btnBackBlu.gif" width="56" height="20" border="0" alt="back"></a></td>
<td align="center" rowspan="2">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle" align="center"><img src="/images/titleCheckoutGrn.gif" border="0"></td>
</tr>
</table>
</td>
<td width="80"><img src="/images/spacer.gif" width="65" height="1" border="0"></td>
</tr>
<tr>
<td width="80" valign="top"><img src="/images/spacer.gif" width="1" height="8" border="0"></td>
</tr>
</table>
<DIV id="processing" style="visibility:hidden"><LAYER id="processingl" visibility="hide"><span class="BlueHeader">Please wait, your order is being processed ...</span></LAYER></DIV>
<DIV id="mainform" style="postion:absolute;top:10">
<FORM action="" method="post" name="Recalc"><input type="hidden" name="Split"><input type="hidden" value="Yes" name="CheckoutRequest"><input type="hidden" name="ButValue"><input type="hidden" name="slotdatestarttime" value="04/10/2001 17:00"><input type="hidden" name="slotdateendtime" value="04/10/2001 19:00"><input type="hidden" name="card_start"><input type="hidden" name="card_exp"><table border="0" width="520" cellspacing="0" cellpadding="0">
<tr>
<td width="40"><img src="/images/shim.gif" border="0" width="40"></td>
<td width="520">
<table border="0" width="520" cellspacing="0" cellpadding="0">
<tr>
<td height="1" colspan="10" bgcolor="green"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="520" height="10"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="520" class="NormalBoldText">Delivery</td>
</tr>
<tr>
<td width="520" height="10"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="520">04/10/2001 17:00<span> - </span>19:00</td>
<td><A href="DeliverySlot.asp?target=Checkout"><img src="/images/btnChangeDelSlotGrn.gif" border="0" alt="Change your delivery slot"></A></td>
</tr>
<tr>
<td width="520" height="10"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td height="1" colspan="10" bgcolor="green"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="520" height="10"><img src="/images/shim.gif" border="0"></td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" width="520" cellspacing="0" cellpadding="0">
<tr>
<td width="40"><img src="/images/shim.gif" border="0" width="40"></td>
<td width="520">
<table border="0" cellpadding="0" cellspacing="0">
<tr height="30" bgcolor="#cccccc">
<td width="10"><img src="/images/shim.gif" border="0"></td>
<td colspan="3" height="30" width="510"><span class="BlueBoldText">       
                                          Please enter your credit card details</span></td>
</tr>
<tr bgcolor="#ffffff" height="40">
<td width="10"><img src="/images/shim.gif" border="0"></td>
<td colspan="3" height="30" width="510"><span class="NormalBoldText">       
                                          We accept the following credit cards:  Visa, Mastercard, Solo, Switch, Delta, American Express and Clubcard Plus.<br>Our acceptance of an order takes place on despatch of the order, at which point the purchase contract will be made and you will be charged for your order.</span></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="500" border="0" cellspacing="0" cellpadding="5">
<table border="0" width="520" cellspacing="0" cellpadding="0">
<tr>
<td width="40"><img src="/images/shim.gif" border="0" width="40"></td>
<td width="520">
<table width="520" border="0" cellspacing="0" cellpadding="8" bordercolor="#000099">
<tr>
<td width="230" colspan="3" align="right" valign="top" bgcolor="#000099"><span class="NormalWhiteText">Cardholder name:</span></td>
<td width="266" colspan="3"><input name="card_name" size="25" style="width:200"><input type="hidden" name="card_type" value="Visa"></td>
</tr>
<tr>
<td width="230" colspan="3" align="right" valign="top" bgcolor="#000099"><span class="NormalWhiteText">Card number:</span></td>
<td width="266" colspan="3"><input name="card_no" size="20" maxlength="19" value="" style="width:200"></td>
</tr>
<tr>
<td width="230" colspan="3" align="right" bgcolor="#000099"><span class="NormalWhiteText">Card expiry date:</span></td>
<td height="27" width="266" colspan="3" class="Globalnorm"><select name="CardExpiryMonth" class="form_r1"><option>--</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option></select><span class="normsmall"> /
                                          <select name="CardExpiryYear" class="form_r1"><option>--</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option></select><span class="NormalBoldText">(mm/yy)</span></span></td>
</tr>
<tr>
<td width="230" colspan="3" valign="top" align="right" bgcolor="#000099"><span class="NormalWhiteText">Card valid from:</span></td>
<td height="27" width="266" colspan="3" class="Globalnorm"><select name="CardValidMonth" class="form_r1"><option>--</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option></select><span class="normsmall"> /
                                          <select name="CardValidYear" class="form_r1"><option>--</option>
<option>97</option>
<option>98</option>
<option>99</option>
<option>00</option>
<option>01</option></select><span class="NormalBoldText">(NotSwitch)</span></span></td>
</tr>
<tr>
<td width="230" colspan="3" align="right" valign="top" bgcolor="#000099"><span class="NormalWhiteText">Issue number if your<BR>card has one :</span></td>
<td colspan="1"><input name="card_iss" size="6" maxlength="2" value=""></td>
<td><span class="NormalBoldText">(Generally some Switch and <br>Solo cards)</span></td>
</tr>
<tr>
<td colspan="6" height="1"><img src="/images/spacer.gif"></td>
</tr>
</table>
</td>
</tr>
</table>
</table><input type="hidden" name="name" value="Mr   Steve Biggs"><input type="hidden" name="addr1" value="17 Pound Avenue"><input type="hidden" name="addr2" value="Stevenage"><input type="hidden" name="addr3" value="Hertfordshire"><input type="hidden" name="addr4" value=" "><input type="hidden" name="addr5" value=""><input type="hidden" name="pcode" value="SG1 3JB  "><table width="520" border="0" cellspacing="0" cellpadding="8" bordercolor="#000099">
<tr>
<td width="520" colspan="5" height="10"><img src="/images/shim.gif" border="0"></td>
</tr>
<table border="0" width="520" cellspacing="0" cellpadding="0">
<tr>
<td width="40"><img src="/images/shim.gif" border="0" width="40"></td>
<td width="520">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="1" colspan="10" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr height="30" bgcolor="#cccccc">
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="9"><img src="/images/shim.gif" border="0"></td>
<td width="510" height="30" colspan="7"><span class="BlueBoldText">Your order details</span></td>
<td width="5"><img src="/images/shim.gif" border="0"></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td height="1" colspan="10" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="9" bgcolor="#FFFFFF"><img src="/images/shim.gif" border="0"></td>
<td width="240" height="30" class="NormalBoldText"><b>Description</b></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="79" height="30" align="center" class="NormalBoldText"><b>Cases</b></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="89" height="30" align="center" class="NormalBoldText"><b>Case Price</b></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="78" height="30" align="right" class="NormalBoldText"><b>Total</b></td>
<td width="5" bgcolor="#FFFFFF"><img src="/images/shim.gif" border="0"></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="520" colspan="10" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="9"><img src="/images/shim.gif" border="0"></td>
<td width="240" align="left" height="26">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><a class="BoldNormalLink" href="browse.asp?type=Item&amp;typeid=5127454">sports socks </a><br></td>
</tr>
<tr>
<td><span class="NormalText"> 6 x
                              750ml</span> bottles
                        </td>
</tr>
</table>
</td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="79" align="center" height="26"><span class="NormalText">3</span></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="89" align="center" height="26">
<font class="NormalText">&#163;20.59</font><nobr></nobr></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="78" align="right"><font class="NormalText">&#163;61.77</font></td>
<td width="5" bgcolor="#FFFFFF"><img src="/images/shim.gif" border="0"></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td height="1" colspan="10" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="9"><img src="/images/shim.gif" border="0"></td>
<td width="240" height="30"><span class="NormalBoldText">Total Before Delivery Charge:</span></td>
<td width="1"><img src="/images/shim.gif" border="0"></td>
<td width="79"><img src="/images/shim.gif" border="0"></td>
<td width="1"><img src="/images/shim.gif" border="0"></td>
<td width="89"><img src="/images/shim.gif" border="0"></td>
<td width="1"><img src="/images/shim.gif" border="0"></td>
<td width="78" align="right"><font class="NormalText">&#163;61.77</font></td>
<td width="5" bgcolor="#FFFFFF"><img src="/images/shim.gif" border="0"></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td height="1" colspan="10" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="9"><img src="/images/shim.gif" border="0"></td>
<td width="240" height="30"><a class="NavyBoldLink" href="/store/help.asp#organisedelivery">Delivery Charge:</a></td>
<td width="1"><img src="/images/shim.gif" border="0"></td>
<td width="79"><img src="/images/shim.gif" border="0"></td>
<td width="1"><img src="/images/shim.gif" border="0"></td>
<td width="89"><img src="/images/shim.gif" border="0"></td>
<td width="1"><img src="/images/shim.gif" border="0"></td>
<td width="78" align="right"><font class="NormalText">&#163;5.00</font></td>
<td width="5" bgcolor="#FFFFFF"><img src="/images/shim.gif" border="0"></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td height="1" colspan="10" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
<td width="9"><img src="/images/shim.gif" border="0"></td>
<td width="240" height="30"><span class="NormalBoldText">Total Price:</span></td>
<td width="1"><img src="/images/shim.gif" border="0"></td>
<td width="79"><img src="/images/shim.gif" border="0"></td>
<td width="1"><img src="/images/shim.gif" border="0"></td>
<td width="89"><img src="/images/shim.gif" border="0"></td>
<td width="1"><img src="/images/shim.gif" border="0"></td>
<td width="78" align="right"><font class="NormalText">&#163;66.77</font></td>
<td width="5" bgcolor="#FFFFFF"><img src="/images/shim.gif" border="0"></td>
<td width="1" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
<tr>
<td height="1" colspan="10" bgcolor="#000099"><img src="/images/shim.gif" border="0"></td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" width="520" cellspacing="0" cellpadding="0">
<tr>
<td width="40"><img src="/images/shim.gif" border="0" width="40"></td>
<td width="520">
<table><tr><td colspan="3" height="30" width="510">
<select name="sport" size="1">
<option selected="selected">Please Select -></option>
<option value="football">football</option>
<option value="cricket">cricket</option>
<option value="hockey">hockey</option>
<option value="other">other</option>
</select>
</td></tr></table>
</td>
</tr>
</table>

</table><br><table border="0" width="520" cellspacing="0" cellpadding="0">
<tr>
<td width="40"><img src="/images/shim.gif" border="0" width="40"></td>
<td width="520">
<table border="0" cellPadding="0" cellSpacing="0" width="520">
<tr>
<td></td>
</tr>
<tr>
<td width="520" colspan="5" height="10"><img src="/images/shim.gif" border="0"></td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" cellPadding="0" cellSpacing="0" width="520">
<tr>
<td width="40"><img src="/images/shim.gif" border="0" width="40"></td>
<td width="520">
<table border="0" cellPadding="0" cellSpacing="0" width="520">
<tr>
<td align="right" colSpan="2" width="50%"><a href="JAVASCRIPT:checkinput(&quot;&quot;);"><img border="0" height="23" name="Purchase" src="/images/btnPurchaseGrn.gif" width="104" value="Purchase" alt="Click here to purchase"></a><br></td>
</tr>
</table>
</td>
</tr>
</table><br></FORM>
</DIV>
</body>

############
Commented:
It worked for me -- Request.Form("sport") was submitted.
Maybe, there is a problem with SSL to submit the form both by POST and by GET (but I never heard of that). Hence, you might try,

document.forms['Recalc'].action = "https://secure.????.com/store/email.asp?Action=Purchase&sport=" + escape(document.forms['Recalc'].sport.value);

in pleasewait(), and change,

strSubj = Request.Form("sport")
to,
strSubj = Request.QueryString("sport")

(If it worked, we would convert the form's action to GET.
Apart from that, the function SUBMIT() never gets called, but that's not the question...)

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept a comment - robbert
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
lavinder
EE Cleanup Volunteer

Explore More ContentExplore courses, solutions, and other research materials related to this topic.