How to get input box value as <a href=?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ddtpmyra
    Contributor
    • Jun 2008
    • 333

    How to get input box value as <a href=?

    How to use the value of the input box to my <a href> link? Below doesnt work. Any ideas?

    Code:
    <tr><td>Contact";
    echo "<input type=\"text\" name=\"contactid\"  id='contactid' </input>
    <a href='edit_entry.php?contactid='$contactid'>Edit";
    thanks!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    use JavaScript. PHP can’t handle events.

    Comment

    • TheServant
      Recognized Expert Top Contributor
      • Feb 2008
      • 1168

      #3
      PHP can only be run before the page has sent (and is visible on a users browser). Javascript works only after the page has sent and is executed by the users browser.

      If you want to change anything after the page has been sent and is visible, you need Javascript, but if it can be before you can use PHP.

      To get a variable sent by a form (eg. method="post") you can have:
      Code:
      echo $_POST['my_input_name'];
      But that will only work once the form has been submitted to the server. Hope that makes sense.

      Comment

      • ddtpmyra
        Contributor
        • Jun 2008
        • 333

        #4
        Thanks for all infos.

        I think I was sucessufully re-work my link code, I just have to use other alternitive way on using quote. I dont know how it works but here's what i did.

        Code:
        <a href=\"edit_entry_contact_edit.php?contactid='$contactid'\">	Edit </a>";

        Comment

        • TheServant
          Recognized Expert Top Contributor
          • Feb 2008
          • 1168

          #5
          Glad it's solved. It's hard to say without the code obviously prior to this. You would have to define $contactid from somewhere, and if it's coming from a form, it would be from $_GET or $_POST. If you're happy, we're happy, but let us know if you have any more trouble or questions.

          Comment

          Working...