SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dropdown list selection

    Hi,
    I know I'm supposed to search the forum for answers before posting but I can't really seem to find the right word for my search. The search feature has been really helpful lately but this time I'm outta clues ....
    Here is what I'm trying to accomplish: I've got a dropdown list that is populated via a php script. Whenever the user selects a value from the list, they have to click on the 'submit' button in order to retrieve the values. I don't want this .... I don't want them to click on the button, rather, retrieve the values from the DB immediately upon selection of a list item. Its like ... I select a value from the dropdown list and it automatically uses its value to retrieve relevant details from the DB, no need to click on any button or anything. How do I do this with js ? Can I accomplish the same with php as well (don't think so ?)

    I hope I'm clear ...
    any help is much appreciated.

    regards,
    mankool

  2. #2
    SitePoint Enthusiast ptolemy's Avatar
    Join Date
    Feb 2002
    Location
    Geneva, Switzerland
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be using the select's onchange event handler.

    For example:

    Code:
    <select onchange='...javascript...'>
    </select>

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You didn't mention whether you wanted to refresh the page or not; there are ways of doing this that avoid a reload entirely. If that's not an issue, you can submit the form directly from the select list:
    Code:
    <select........onchange="if(selectedIndex!=0)this.form.submit()">
    <option>dummy</option>
    <option value="aaa">choice</option>
    <option value="bbb">choice</option>
    ........
    However...this is considered bad UI design, since the submission should arguably involve a different action from the list selection; the above allows no leeway for an incorrect choice.
    ::: certified wild guess :::

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help ... working just as I wanted

    thank you (both of you)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •