passing a hard coded value from a link to a field on a form

Discussion in 'Programming' started by cmb75, Dec 11, 2008.

  1. #1
    I have a link on page that I want to use to pass a hard coded value from the link to a field on a form on another page.

    For example when someone clicks <a href="contact.html?Comments=Big%20Red%20Shoe">Email for More Info</a> I'd like the value "Big Red Shoe" to carry over and pre-populate the Comments field of the form on the contact.html page.
    Any thoughts on the best way to accomplish this?
     
    cmb75, Dec 11, 2008 IP
  2. Christopher

    Christopher Peon

    Messages:
    482
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What do you have to work with? php? asp?
     
    Christopher, Dec 11, 2008 IP
  3. cmb75

    cmb75 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm primarily a web designer, but am somewhat familiar with javascript and php.
     
    cmb75, Dec 11, 2008 IP
  4. cmb75

    cmb75 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    In case anybody else ever needs this here's what I figured out.

    Link:
    <a href="contact.html?Comments=Big Red Shoe">Email for More Info</a>

    Text Field:
    <input type="text" name="Comments" value="<?= $_GET['Comments'] ?>">

    Text Area:
    <textarea name="textfield" cols="30"><?= $_GET['Comments'] ?></textarea>
     
    cmb75, Dec 11, 2008 IP
  5. Christopher

    Christopher Peon

    Messages:
    482
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sorry, been away from the computer this afternoon/evening. I was going to suggesting something along those lines :) Glad you found it!
     
    Christopher, Dec 11, 2008 IP
  6. Sapphiro

    Sapphiro Well-Known Member

    Messages:
    1,242
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    175
    #6
    hmmm, just for an add on, if it's ASP.NET, it would be..

    
    a href="contact.aspx?Comments=Big%20Red%20Shoe">Email for More Info</a>
    
    ...
    
    string commentValue = Request.QueryString["Comments"];
    
    
    lblTest.Text = commentValue; (make sure lblTest is already declared)
    
    
    Code (markup):
    :)
     
    Sapphiro, Dec 13, 2008 IP