SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jan 2008
    Location
    Palm Harbor, FL
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow Changing text upon selecting from a drop-down menu

    On a page for product descriptions, I have a MySQL query that returns a list of purchase options and the price of each option.

    There is a drop-down field which lists the names of each option. To the right, the price of the selected option is displayed.

    Upon selecting a different option, how can I have the displayed price change to that of the newly selected option?

  2. #2
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont remember the javascript function properly, You can search for selected index for dropdown menu. After selecting it you can change the value of the textbox or other selectbox value.

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Morthian View Post
    There is a drop-down field which lists the names of each option. To the right, the price of the selected option is displayed.

    Upon selecting a different option, how can I have the displayed price change to that of the newly selected option?
    Start from a point of no scripting, because you will have people in that situation.

    When the drop-down field is changed, you need a submit near it to update the page prices, so that the server-side can update the on-screen prices.

    Then, you can use javascript to update the prices without the page refresh, buy taking over the onsubmit event for the price update. You can then either do the work separately from javascript, or you can use ajax to fetch the updated prices from the server.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •