Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

form submission with Javascript

Javascript coding ..

Moderators: macek, egami, gesf

form submission with Javascript

Postby ktsirig » Mon Dec 18, 2006 1:50 pm

Hello!
I am searching over the net for quite a long, but I have almost no idea concerning Javascript so I can't figure out the solution to my problem...
I have a form that show a drop-down menu, which takes all its values through a Mysql database via PHP. What I want to do is to submit the form to the next page (from index.php ---> retrieve_data.php) without the need of a "Submit" button.
When the user selects one of the given options, automatically he will be redirected to retrieve_data.php?id=5 for example...

Thank you in advance!
ktsirig
New php-forum User
New php-forum User
 
Posts: 36
Joined: Mon Sep 19, 2005 12:22 pm

Postby gesf » Mon Dec 18, 2006 5:44 pm

Hey ktsirig. You need to use the onchange event of your select tag.
Example:
Code: Select all
<form method="post" action="retrieve_data.php">
     <select name="mydropdown" onchange="this.form.submit();">
          <option value="1">Option 1</option>
          <option value="2">Option 2</option>
          <option value="3">Option 3</option>
     </select>
</form>
After submittion, retrieve the option posted through: $_POST['mydropdown']
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby ktsirig » Tue Dec 19, 2006 1:18 am

Thanx gesf! Always willing to help!

Thanx a lot!
ktsirig
New php-forum User
New php-forum User
 
Posts: 36
Joined: Mon Sep 19, 2005 12:22 pm

Postby gesf » Tue Dec 19, 2006 2:25 am

:D
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.