Jump to content

Problem with posting a form......


boylesg
 Share

Recommended Posts

Below is a cut down verion of the html that the client recieves and basically consists of two sets of repeating controls of a possible 22.Each set of controls includes and "+10", "+1", "-10" and "-1" buttons that increment and decrement a readonly "Quantity" field.The "-10" and "-1" always work, with Response.Form always containing the expected data.The "+10" and "+1" only work, with Response.Form containing the expected data, if there is a single set of controls. As soon as I add the second set of controls as below they no longer work properly, i.e. the forms appears to post and refresh itself but Response.Form is undefined.If I comment out the line of bold text then the "+10" and "+1" buttons always work with more than one set of controls.Is this just another false lead that will never lead me to the cause of this problem?I am at a total loss with this problem, short of f'ing off the buttons, making the quantity field editable and be done with it.This f'ing frustrating. <html> <head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Small Trees</title><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><style fprolloverstyle>A:hover {color: #FF0000; font-family: Arial Black; text-decoration: underline}</style> <p> <script language=javascript> function GetQuantity(MyFormID, ElementID){ var MyForm = document.getElementById(MyFormID); var Index = 0; var Quant = 0; while (Index < MyForm.length) { if (MyForm.elements[index].id == ElementID) { Quant = Number(MyForm.elements[index].value); break; } else Index++ } return Quant;} function SetQuantity(MyFormID, ElementID, NewQuant){ var MyForm = document.getElementById(MyFormID); var Index = 0; while (Index < MyForm.length) { if (MyForm.elements[index].id == ElementID) { MyForm.elements[index].value = String(NewQuant); break; } else Index++ }} function IncQuantity(Amount, QuantityObjectID){ var NewQuant = GetQuantity("MyForm", QuantityObjectID) + Amount; SetQuantity("MyForm", QuantityObjectID, NewQuant); MyForm.submit();} function DecQuantity(Amount, QuantityObjectID){ var NewQuant = GetQuantity("MyForm", QuantityObjectID) - Amount; if (NewQuant < 0) NewQuant = 0; SetQuantity("MyForm", QuantityObjectID, NewQuant); MyForm.submit();} function GoToCheckout(){ window.open("Order.asp", "_self");} </script></p> ***********************************************************************************<br>undefined<br>***********************************************************************************<br>***********************************************************************************<br>undefined<br><br><br>Index1 = -1<br>Index2 = -1<br>***********************************************************************************<br>***********************************************************************************<br> <br>***********************************************************************************<br> <!--mstheme--><link rel="stylesheet" type="text/css" href="_themes/ice174/ice11111.css"><meta name="Microsoft Theme" content="ice174 1111, default"><meta name="Microsoft Border" content="none, default"></head> <body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0"> <form name="MyForm" id="MyForm" action="test.asp" method="post"><p align="left"><font face="Arial" size="4" color="#0000FF"><b><u><a name="Trees 15 metres or less in height...">Trees 15 metres or less in height...</a></u></b></font><p align="center"> <table border="1" cellpadding="5" width="740"><tr><td align="center"><b><font face="Arial" size="2">Photograph</font></b></td><td align="left"><b><font face="Arial" size="2">Details</font></b></td></tr><tr><td align="center"><font face="Arial" size="2"><a href="http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_implexa.jpg" target="_self"><img border="0" src=http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_implexa.jpg width="400"></a></font></td><td align="left"><font face="Arial" size="2"><label for="ScientificName1"><b>Scientific name:</b></label><br><input type="text" name="ScientificName1" size="45" value="Acacia implexa" readonly=true><br><font face="Arial" size="2"><b>Common name: </b><br><a name="Lightwood">Lightwood</a></font><br><br><b>Distribution of the species: </b><br><a href="http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_implexa_.png" target="_self">  <img border="0" src="http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_implexa_.png" width="133.33333333333334"></a></font><br><font face="Arial" size="2">  Click <a href="http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_implexa_.png">here</a> to enlarge image</font><br><br><font face="Arial" size="1">  Maps derived from Australia's Virtual Herbarium(<a href="http://www.rbg.vic.gov.au/avh/">AVH</a>) and<br>  used with permission of the Council of Heads of Australasian<br>  Herbaria(<a href="http://www.chah.gov.au//">CHAH</a>)</font><br><br><font face="Arial" size="2"><b>Flowering Period: </b>December - March<br>n<b>Edible parts: </b><br><b>Maximum height: </b>12m<br><b>Maximum spread: </b>3m<br><b>Drought tolerance: </b><br><table border="1" cellpadding="0" cellspacing="1" width="175" height="1"><tr><td width="10" align="right"><b><font face="Arial" size="1">LOW</font></b></td><td width="8" bgcolor="LimeGreen" bordercolor="#000000"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="10" align="left"><b><font face="Arial" size="1">HIGH</font></b></td></tr></table><br><b>Preferred soils: </b>Clay or sedimantary to loamy soils.<br><b>Preferred aspect: </b>Full sun to light shade.<br><b>Waterlogging tolerance: </b>Seasonal<br><b>Comments: </b><br>b>Origin: </b>Local native (Melbourne region)<br><label for="Size1"><b>Size:</b></label>  <input type="text" name="Size1" size="14" value="Tube" readonly=true><br><label for="Price1"><b>Price:</b></label>  <input type="text" name="Price1" size="6" value="$3.50" readonly=true><br><label for="ItemID1"><b>Code:</b></label>  <input type="text" name="ItemID1" size="8" value="ST001" readonly=true><br><label for="Quantity1"><b>Quantity: <b></label><input type="text" name="Quantity1" id="Quantity1" value="0" size=2 readonly=true>   <input type="button" name="addbox1" id="addbox1" value=" +1 " onclick="IncQuantity(1, 'Quantity1')"> <input type="button" name="add10box1" id="add10box1" value=" +10 " onclick="IncQuantity(10, 'Quantity1')"><input type="button" name="subbox1" id="subbox1" value=" -1 " onclick="DecQuantity(1, 'Quantity1')"> <input type="button" name="sub10box1" id="sub10box1" value=" -10 " onclick="DecQuantity(10, 'Quantity1')"><br><br><input type="button" onclick="GoToCheckout()" value="Shopping Cart" name="ShoppingCart1"></font></td></tr><tr><td align="center"><font face="Arial" size="2"><a href="http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_melanoxylon.jpg" target="_self"><img border="0" src=http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_melanoxylon.jpg width="400"></a></font></td><td align="left"><font face="Arial" size="2"><label for="ScientificName2"><b>Scientific name:</b></label><br><input type="text" name="ScientificName2" size="45" value="Acacia melanoxylon" readonly=true><br><font face="Arial" size="2"><b>Common name: </b><br><a name="Blackwood">Blackwood</a></font><br><br><b>Distribution of the species: </b><br><a href="http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_melanoxylon_.png" target="_self">  <img border="0" src="http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_melanoxylon_.png" width="133.33333333333334"></a></font><br><font face="Arial" size="2">  Click <a href="http://i209.photobucket.com/albums/bb196/boylesg/SmallTrees/Acacia_melanoxylon_.png">here</a> to enlarge image</font><br><br><font face="Arial" size="1">  Maps derived from Australia's Virtual Herbarium(<a href="http://www.rbg.vic.gov.au/avh/">AVH</a>) and<br>  used with permission of the Council of Heads of Australasian<br>  Herbaria(<a href="http://www.chah.gov.au//">CHAH</a>)</font><br><br><font face="Arial" size="2"><b>Flowering Period: </b>July - October<br>n<b>Edible parts: </b><br><b>Maximum height: </b>10m<br><b>Maximum spread: </b>4m<br><b>Drought tolerance: </b><br><table border="1" cellpadding="0" cellspacing="1" width="175" height="1"><tr><td width="10" align="right"><b><font face="Arial" size="1">LOW</font></b></td><td width="8" bgcolor="LimeGreen" bordercolor="#000000"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="LimeGreen"> </td><td width="8" bgcolor="Snow"> </td><td width="10" align="left"><b><font face="Arial" size="1">HIGH</font></b></td></tr></table><br><b>Preferred soils: </b>Clay or sedimantary to loamy soils.<br><b>Preferred aspect: </b>Full sun to light shade.<br><b>Waterlogging tolerance: </b>Frequent<br><b>Comments: </b>Excellent screen.<br>b>Origin: </b>Local native (Melbourne region)<br><label for="Size2"><b>Size:</b></label>  <input type="text" name="Size2" size="14" value="Tube" readonly=true><br><label for="Price2"><b>Price:</b></label>  <input type="text" name="Price2" size="6" value="$3.50" readonly=true><br><label for="ItemID2"><b>Code:</b></label>  <input type="text" name="ItemID2" size="8" value="ST002" readonly=true><br><label for="Quantity2"><b>Quantity: <b></label><input type="text" name="Quantity2" id="Quantity2" value="0" size=2 readonly=true>   <input type="button" name="addbox2" id="addbox2" value=" +1 " onclick="IncQuantity(1, 'Quantity2')"> <input type="button" name="add10box2" id="add10box2" value=" +10 " onclick="IncQuantity(10, 'Quantity2')"><input type="button" name="subbox2" id="subbox2" value=" -1 " onclick="DecQuantity(1, 'Quantity2')"> <input type="button" name="sub10box2" id="sub10box2" value=" -10 " onclick="DecQuantity(10, 'Quantity2')"><br><br><input type="button" onclick="GoToCheckout()" value="Shopping Cart" name="ShoppingCart2"></font></td></tr></table></form> </body> </html>

Link to comment
Share on other sites

I believe that this was just another false lead and is not really the cause of the problem.Could I be having some sort of a sychronisation problem?I.E. Because I am posting the form to the same page, the form is quite long and takes a bit for the server to process it and load all the data into Request.Form, my re-loaded asp pages starts processing Request.Form before the server has sent it to my re-loaded asp page such that it tries to process Request.Form before it has been received from the server, hence it is undefined.In which case my only option is to post to a pissy little popup page which does the processing of Request.Form contents and then returns to the original page. It seemed to solve the problem when I had my form post to another much smaller asp file that I was mucking around with.

Link to comment
Share on other sites

If you pass the input element ID to the GetQuantity and SetQuantity functions, why do you loop through all fields in the form instead of just getting that one element specifically?

Because I am posting the form to the same page, the form is quite long and takes a bit for the server to process it and load all the data into Request.Form, my re-loaded asp pages starts processing Request.Form before the server has sent it to my re-loaded asp page such that it tries to process Request.Form before it has been received from the server, hence it is undefined.
No, it's not going to start processing the ASP code until it's done all of the setup tasks, including populating Request.Form. However, I've seen a bug with IE under certain circumstances where IE did not include a content-type header, and that caused ASP to not popuplate the form data. It was all submitted, I could access the form data manually by parsing the request body myself, but it wouldn't do it automatically because IE left out the content type for the form, which should be "application/x-www-form-urlencoded". When the server receives that content type it knows to populate the form collection with all of the data. I had to use an application like Fiddler to figure that out, Fiddler will let you see the entire request so you can check if the correct content-type header is being sent to the server. If you're using IE, that might be the issue. If the same thing happens in multiple browsers it would be something else. If IE is the problem, you can use the Request.BinaryRead method to read the request body and parse it yourself. Note that using either Request.Form or Request.BinaryRead will cause the other to become unavailable.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...