Jump to content

Setting Form Values And Submitting


johnnyg24

Recommended Posts

I have a script that sets the value of a text box and then is submitting it to our server. When the server gets the information it displays a thumbnail page with our products on it. If I manually type a value into the text box and submit it, I get the results that I am expecting. However, if I use the script to set the text box value and then submit the form, I don't get the results I am looking for. I do know however that the text field is being set because I can see it change right before the form gets submitted. Any help as to how to get this form to work the same way it does when manually enter and submit data would be helpful. Thanks.Form:

<form id="bookSearch" name="bookSearch" method="post" action="webwiz/wwiz.asp?wwizmstr=W_SKU_SEARCH">	<input type="text" id="bookNumber" name="bookSearchText" class="inputInstructions" value="Enter Book Number"/>		<input type="hidden" name="wwizmstr" value="W_SKU_SEARCH" />	<input type="submit" name="bookSubmit" value="Search" /></form>

Setting and submitting script:

function getThumbnails(nbr) {	document.getElementById("bookNumber").value = nbr;	document.bookSearch.submit();}

script setting the parameter 'nbr' and calling 'getThumnails(nbr);

function bookTable(selection) {			var nr = 0;		deleteRows(document.getElementById("books"));			 for (var i = 0; i < xDoc.getElementsByTagName("bk").length; i++) {				 if (xDoc.getElementsByTagName("cls")[i].firstChild.data == selection) {									if (nr % 3 == 0){								  imgRow = document.getElementById("books").insertRow(-1);					  txtRow = document.getElementById("books").insertRow(-1);				}								var cellA=imgRow.insertCell(0);								var cellAAA=txtRow.insertCell(0);								im = document.createElement("img");			im.src = "http://www.estout.com/Images/" + xDoc.getElementsByTagName("bkid")[i].firstChild.data + ".jpg";				im.setAttribute('width', 80);		 		im.setAttribute('height', 80);				im.setAttribute('align', 'center');				cellA.appendChild(im);					lk = document.createElement("a");				lk.href = "java script:getThumbnails("+ xDoc.getElementsByTagName("bkid")[i].firstChild.data +");";				lk.innerHTML = xDoc.getElementsByTagName("bkid")[i].firstChild.data + "<br>" + xDoc.getElementsByTagName("bkde")[i].firstChild.data;				lk.setAttribute('class', 'whatsNewDetail');				lk.setAttribute('align', 'center');				cellAAA.appendChild(lk);				nr++								}							}				}	function deleteRows(tbl) {	while (tbl.rows.length > 0) {		tbl.deleteRow(0);		 }	  }

Link to comment
Share on other sites

I have tried just setting the value with the script and then manually submitting the form and it works as expected. Could there be something happening when the script submits the form? I would think that if there were characters or spaces being added to the value it would occur when the script sets the value not when it is being submitted.

Link to comment
Share on other sites

There's nothing about the form.submit method that's going to change the values in the form before it submits. If the value is coming through incorrectly, start on the ASP page to test the value and work backwards until you figure out where it's getting messed up. There's a chain of events happening, so start at the end and work back.

Link to comment
Share on other sites

When the form is submitted it looks like it is just going to the page specified in the action. The page loads and seems to be waiting for further input. When the form's value is set by the script and the submit button is manually pressed, our server processes the request. It's only when the script is trying to submit the form that nothing seems to work. I have listed the the link below. Maybe you can see what I am talking about.Page trying to submit formIf you select one of the books it should set the value of the form and then submit it.Page setting value but you have to manually submit itThe submit button is at the bottom of the page. You can also see which book number is being passed.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...