Hi..
im PHP user..
i want to get a text box value to the Php variable by clicking hyperlink and i want to send that value to database using mysql query. i want to know that is how can i get text box value to the PHP variable clicking by hyperlink. not by clicking submit button..
thank you..

hmm... if I understand you, you have a text box that a user will enter data into and when they click a link (<a href='blah.php'>) you want the contents of that text field passed as a parameter to the file on the link (blah.php). Is that right?

I think you would do this with javascript on the page with the text box using an onclick="do this stuff here" function to get the contents of the text box and modifying the href.

I'm just guessing here but thats where I'd start...

try to use
<a href='blah.php?textboxname='+formname.textboxname.value>
something like that.

yep... what he said! ^^^^^^

yeah ppetree u got my prob.. i can get that value using java script . bt thing is i dont knw hw to get value from java script variable to php variable. coz i need that value pass to php variable. can u plz tell me..

<a href='blah.php?textboxname='+formname.textboxname.value>

just read using $_GET

alternatively, use an ordinary FORM, and submit it using javascript.

onclick = "document.forms[0].submit()"

<input type="text" name="url_param" id="url_param" /> 
<input type="button" onclick="prepare_link();" value="Do it!" /> 
 
<a href="http://whatever.com" id="target_link" onclick="append_link()">Click Your New Link!</a>
<script type="text/javascript"> 
function append_link() { 
  var url_param = document.getElementById('url_param'); 
  var target_link = document.getElementById('target_link'); 
 
  if ( ! url_param.value ) { 
      return false;   
  } 
 
  target_link.href = target_link.href + '/=url_param?' + escape(url_param.value); 
} 
</script>
<script type="text/javascript">
function ftest(){
window.location="totherecievingpagedatabasesave.php?test="+document.getElementById('test').value;
}
</script>

<input type="text" name="test" id="test" />
<a href="javascript:void(0);" onclick="ftest()">click me</a>

then get the text box variable on the receiving end via $_GET;

commented: thank you +0

I think I like Vault's better! LOL

Obviously, there is more than one way to do this!

Thank you for all to answering me.. i did it.. and thanx vaultdweller123.. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.