469,904 Members | 1,898 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

Reloading a PHP form without using submit button

82
Hi,

I have a list that I want every time the list is changed I want to change other elemnets in the form automatically without pressing any submit button, for example an update second list. All this will be done with PHP and Javascript.
Is it possible?
Mar 3 '08 #1
4 2414
Hi,

try to use the onChange-property of the select-element to call the form again. (You can use JavaScript-code to pass variables (e.g. with the selection) to a PHP-script, which then does the changes you want.)
Maybe just using JavaScript might do the job as well.
Expand|Select|Wrap|Line Numbers
  1. <form action="select.htm">
  2.   <p>Your ordering:</p>
  3.   <p>
  4.     <select name="Pizza" size="5"
  5.         onchange="alert(this.form.Pizza.options[this.form.Pizza.selectedIndex].value)">
  6.       <option value="P101">Pizza Napoli</option>
  7.       <option value="P102">Pizza Funghi</option>
  8.       <option value="P103">Pizza Mare</option>
  9.       <option value="P104">Pizza Tonno</option>
  10.       <option value="P105">Pizza Mexicana</option>
  11.       <option value="P106">Pizza Regina</option>
  12.       <option value="P107">Pizza de la Casa</option>
  13.       <option value="P108">Pizza Calzone</option>
  14.       <option value="P109">Pizza con tutti</option>
  15.     </select>
  16.   </p>
  17. </form>
  18.  
(Code from: http://de.selfhtml.org/html/formulare/auswahl.htm)

Regards,
Bertram
Mar 4 '08 #2
Look into AJAX -- it's based off of javascript. I just started learning it, so I won't begin to post any examples, but if you google it, you can find some good tutorials.
Mar 4 '08 #3
ronverdonk
4,258 Expert 4TB
Look into AJAX -- it's based off of javascript. I just started learning it, so I won't begin to post any examples, but if you google it, you can find some good tutorials.
Why would you loook into Ajax? Using just plain JavaScript will do what you want, without going to the server.

Ronald
Mar 4 '08 #4
Why would you loook into Ajax? Using just plain JavaScript will do what you want, without going to the server.

Ronald
Sorry, I meant use Ajax if you needed to populate from a database or elsewhere.

I have no idea what or where he needs to populate the second list from, so Ajax might be a perfectly legitimate solution.
Mar 4 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Steve Benson | last post: by
8 posts views Thread by bettina | last post: by
6 posts views Thread by iwearwatches | last post: by
3 posts views Thread by D. Shane Fowlkes | last post: by
6 posts views Thread by varkey.mathew | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.