Reloading a PHP form without using submit button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raknin
    New Member
    • Oct 2007
    • 82

    Reloading a PHP form without using submit button

    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?
  • boert89
    New Member
    • Mar 2008
    • 5

    #2
    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.
    Code:
    <form action="select.htm">
      <p>Your ordering:</p>
      <p>
        <select name="Pizza" size="5"
            onchange="alert(this.form.Pizza.options[this.form.Pizza.selectedIndex].value)">
          <option value="P101">Pizza Napoli</option>
          <option value="P102">Pizza Funghi</option>
          <option value="P103">Pizza Mare</option>
          <option value="P104">Pizza Tonno</option>
          <option value="P105">Pizza Mexicana</option>
          <option value="P106">Pizza Regina</option>
          <option value="P107">Pizza de la Casa</option>
          <option value="P108">Pizza Calzone</option>
          <option value="P109">Pizza con tutti</option>
        </select>
      </p>
    </form>
    (Code from: http://de.selfhtml.org/html/formulare/auswahl.htm)

    Regards,
    Bertram

    Comment

    • muppetjones
      New Member
      • Feb 2008
      • 11

      #3
      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.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Originally posted by muppetjones
        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

        Comment

        • muppetjones
          New Member
          • Feb 2008
          • 11

          #5
          Originally posted by ronverdonk
          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.

          Comment

          Working...