SitePoint Sponsor

User Tag List

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

    Changing / Posting 2 variables from 1 select option?

    Hello,

    Here is my problem. I have 3 pieces of information I'm trying to pass through a form:
    • A product size
    • A product UPC
    • A product price
    Example products:

    10cm cable
    UPC: #10100A
    Price: $10.00

    12cm cable
    UPC: #12100A
    Price: $13.00

    I want users to be able to select the cable length they need from a drop down, and have the UPC and price automatically applied when the form gets posted.

    Anyone know how to do this? I've only ever used it with one variable per select option.

    Thanks!

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2006
    Location
    Nantwich, Cheshire
    Posts
    468
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Surely just supplying the UPC will be sufficient for your form script to retrieve the other information from the product database? I mean, it looks like the item with the different length has a different UPC as it's a pre-built cable, so that's the point of having a UPC.

    If that's not the case, I think you'd need to have some javascript that runs on change of the drop-down which populates a couple of hidden form variables with the other values prior to posting the form.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, there is no interaction with a database at all. This is strictly HTML with Paypal add-to-cart buttons. I'm able to change only 1 variable at a time based on drop-down selection. I was just wondering if it was possible to somehow change two without resorting to client-side JavaScript.

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2006
    Location
    Nantwich, Cheshire
    Posts
    468
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    OK, I imagined that the page was perhaps generated from a database and submitted back to the same server.

    I can't think of a way without Javascript, but others might know better.


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
  •