Results 1 to 5 of 5

Thread: Sending a value to a form from a link

  1. #1
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Sending a value to a form from a link

    Edit: Moved from the Javascript Forum


    Greetings all ....

    This may be more of a PHP issue, but I thought I'd start here.

    I have an art web site. There will be paintings, jewelry, home decor items, etc. Each item will be highlighted with a short description within a div tag.

    I'm also using SSIs for the footer and banner.

    What I'd like to do is have one form for item inquiries. From each featured item I would like to have a button/link that can be clicked to make an inquiry. That link would take the person to a form which can then be filled out with name, email, phone, etc. However, I'd really like to have a field pre-populated with an ID from the featured item they just clicked from.

    Is there a simple way of doing this? Using php, I'm not sure how to carry the ID value from the featured item and paste it into the value= field in the form.

    Thank you for your help
    Last edited by jscheuer1; 12-30-2008 at 05:09 PM. Reason: Moved from the Javascript Forum

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If you are loading a new page for this form:

    link would take the person to a form
    it should be done with PHP. Ask in the PHP section for details if the below general explanation isn't enough:

    The easiest way would be to have a form send the data.

    On your sending page, the form could have radio buttons to determine this value you are sending (radio buttons may be named all of one group, so only one may be checked, and the value passed will be the value of the one checked).

    Then the form data could be sent via post or get to the new page, where it is a simple matter in PHP to parse the GET or POST data from the sending form and populate the field on the new page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    This isn't the safest script....
    somefilename.php:
    HTML Code:
    <form action="getSelected.php" method="GET">
    <label for="1">Jewelry</label><input type="radio" name="item" value="Jewelry" id="1"/>
    <label for="2">Paintings</label><input type="radio" name="item" value="Paintings" id="2"/>
    <label for="3">Walls</label><input type="radio" name="item" value="Walls" id="3"/><br />
    <label for="4">Ceilings</label><input type="radio" name="item" value="Ceilings" id="4"/>
    <label for="5">Carvings</label><input type="radio" name="item" value="Carvings" id="5"/>
    <input type="submit" name="submit"/>
    </form>
    getSelected.php:
    PHP Code:
    <?php
    if(isset($_GET['submit'])){
      echo 
    "You selected ".$_GET['item'].", right?";
    }
    ?>
    Jeremy | jfein.net

  4. The Following User Says Thank You to Nile For This Useful Post:

    OliveStreet (12-30-2008)

  5. #4
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks, Niles. I know this posting got moved to PHP from javascript. I was hoping it could be done with javascript alone, but I guess not. I posted my query in another forum last night and someone sent me a good solution, albeit, done in PHP.

    Thanks, again, for your response. I really appreciate your help.

    P.S.: I wanted to put a "resolved" next to my post yesterday, but I couldn't figure out how.

  6. #5
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I'm glad to help you anytime.

    To put a resolved:
    Go to your 1st post, and click edit at the bottom right. Then Click 'Go advanced', next to the thread name there should be a drop down, select 'RESOLVED'.
    Jeremy | jfein.net

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
  •