Connecting Tech Pros Worldwide Forums | Help | Site Map

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

ddtpmyra's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: CA
Posts: 222
#1: 3 Weeks Ago
How to use the value of the input box to my <a href> link? Below doesnt work. Any ideas?

Expand|Select|Wrap|Line Numbers
  1. <tr><td>Contact";
  2. echo "<input type=\"text\" name=\"contactid\"  id='contactid' </input>
  3. <a href='edit_entry.php?contactid='$contactid'>Edit";
thanks!

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,652
#2: 2 Weeks Ago

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


use JavaScript. PHP can’t handle events.
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#3: 2 Weeks Ago

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


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:
Expand|Select|Wrap|Line Numbers
  1. echo $_POST['my_input_name'];
But that will only work once the form has been submitted to the server. Hope that makes sense.
ddtpmyra's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: CA
Posts: 222
#4: 2 Weeks Ago

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


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.

Expand|Select|Wrap|Line Numbers
  1. <a href=\"edit_entry_contact_edit.php?contactid='$contactid'\">    Edit </a>";
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#5: 2 Weeks Ago

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


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.
Reply