1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

javascript and php

Discussion in 'PHP' started by vijaykoul, Feb 26, 2005.

  1. #1
    hi frndz,

    I am trying out the following thing:

    I have two dropdown boxes on a form.
    the contents of the both are retrieved from the database.
    the contents of second one are based on the selection from the first one.
    what i am doing is that i am using a submit function on the "onchange" event of first dropdown.
    what it does is that it refreshes the whole form. till now it is fine but i want to add a submit button on the form and set the action attribute of the form to suppose "index.php". when ever i choose from the first drop down, it takes me to "index.php" since the attribut is set to index.php.

    I do not want to do that as I want to pass the contents of the second form to index.php

    Please help
     
    vijaykoul, Feb 26, 2005 IP
  2. frud0

    frud0 Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use a different script for "refreshing" the form.. dont keep it the same as the action form
     
    frud0, Feb 26, 2005 IP
  3. nullbit

    nullbit Peon

    Messages:
    489
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #3
    nullbit, Feb 26, 2005 IP
  4. vijaykoul

    vijaykoul Guest

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    what script should i use to refresh the form
     
    vijaykoul, Feb 26, 2005 IP
  5. frud0

    frud0 Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    When you select an element from the list... make a script called "refresh.php" which has your code to fetch elements for the second list. Use THAT in your "onchange" event... and let the form action be index.php. You could actually do with index.php too... like call something like index.php?action=populate and then add similar code to the PHP script

    if ($action = "populate")
    {
    blahblah; <--- Your "refresh" code comes here
    }
    Code (markup):
     
    frud0, Feb 26, 2005 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #6
    sarahk, Feb 27, 2005 IP