PDA

View Full Version : Form on external page



rashnu
09-03-2008, 08:47 AM
1) Script Title: Ajax Tabs Content Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/

3) Describe problem:

I've got a form on one of my external pages. When i click on the submit button the page reloads. the problem is the page won't load in my container no mater what i try. Is this possible or do i have to change the form?

what i have now :

<form action='" . $_SERVER['PHP_SELF'] . "' method='post'>
Category: <select name='cat'>
<option>All</option>
<option>Movies</option>
<option>Music</option>
<option>Apps</option>
<option>Series</option>
<option>Other</option>
</select>
<input type='submit' name='knop' value='Filter'>
</form>

Thank you for taking a look at this.
Rashnu

codeexploiter
09-03-2008, 09:39 AM
When you submit a form using it usually reloads the page completely if the action contains either the current page name or "". It is difficult to submit a form through a submit button without reloading your current page (I mean retaining the state of your current page).

What you can do is that for submitting the form you can use AJAX instead of using the normal HTTP method. In that case you have to convert the "submit' button into a normal button and attach a JavaScript function with it. The JavaScript function will issue the AJAX call, which would be this page itself and you can handle the success part or failure part of the AJAX processing without much trouble.

In this idea as your current page is not being reloaded you'll be able to maintain the current state of your page without any issues.

Hope this helps.

rashnu
09-03-2008, 09:47 AM
Thank you for the quick response.

Could you give an example perhaps? and do I have to place the button inside the form then?

Thx,
Rashnu