Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ajax onsubmit

Status
Not open for further replies.

ibjdt

Programmer
Nov 25, 2002
63
i have the form and ajax below. i want the form to use the ajax script to call a perl cgi script to display results to the screen in a div tag. i have it working on other pages, but here when the ajax script finishes, the page refreshes??

Code:
<script type="text/javascript">
function ajaxcombo(loadarea){
var lkey = document.lform.keyword.value;
	if (lkey == "")
	{
		alert ("\n\nEnter Search Term.\n\n");
		return false;
	}
var href=myUrl/lookup.cgi?keyword='+lkey;
ajaxpage(href, loadarea);
}
</script>


<form name=lform id=lform onsubmit="keyword.value=keyword.value.toUpperCase(); ajaxcombo('pns');" action="">
<input type=text name=keyword class=input><br>
<input type=submit value=submit class=input>
<div id=pns></div>
</form>

thanks.
 
You need to return false to the onsumbit handler:

Code:
onsubmit="keyword.value=keyword.value.toUpperCase(); [!]return([/!]ajaxcombo('pns')[!])[/!];"

So make sure that the "ajaxcombo" returns true if you want the submission to occur, false otherwise.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
ok - thanks for the help. the return didn't work so i kept digging and found the problem.

there's an external script that actually does the work of showing the results in the div tag. it uses the current page address during execution, but the current page is cgi generated so the ajax script doesn't get all the variables used to create the cgi page so it basically just refreshes.

can this be done another way?

i have outlined the intent in my first post in this thread. i have a 'lookup' form where i give users capability to type partial entries and, onsubmit, an ajax script would execute a perl script to look for possible matches and display those below the lookup form.

thanks.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top