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!

Sumbit to a div

Status
Not open for further replies.

apex82

Programmer
Mar 2, 2009
127
GB
I have the following section of code:

Code:
if (intErrors == 0)
{
document.forms[0].action='inc_thanks.asp';
document.forms[0].submit();
} else {
...

How would I make it so the inc_thanks page shows in a div rather than the next page?

I’ve been searching on Google for a similar examples but unable to find anything.

Thanks.
 
Hi

You can not. It can be loaded into a [tt]window[/tt] object only, so a browser window, a tab or an [tt]iframe[/tt] element.

Or while you asked in the AJAX forum, you can do it with AJAX too :
[ul]
[li]set an [tt]onsubmit[/tt] event handler for the [tt]form[/tt], which to do :[ul]
[li]put together the data to submit[/li]
[li]submit it using [tt]XMLHttpRquest[/tt][/li]
[li]set up an event handler to process returned data, which to do :[ul]
[li]set the [tt]div[/tt]'s [tt]innerHTML[/tt] to the returned data[/li][/ul][/li]
[li]stop the default submitting to happen[/li][/ul][/li]
[/ul]
Note that the server-side script should not return a whole HTML document, only the chunk suitable to be put inside the [tt]div[/tt].

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top