jawad hamzah Posted January 22, 2009 Share Posted January 22, 2009 i have form like this <form action='page1.php' method='post'> <input type='text' id='mytext'> <a href='page2.php?var1=hello&var2=(here i want to but input text value ... How?)'>Go To Page2</a></form>I want when i click Go To Page2 open page2.php and print this :var2 : value of mytextfor example if i type in input text this word (Jawad) and click Go To Page then open page2.php and type in it :Hello : JawadMy qession : How i ger the variable (var2) the value of (mytext) in same form Notic : I know to do this by submit button but i want to make it by variabels .Thanks Link to comment Share on other sites More sharing options...
Lulzim Posted January 22, 2009 Share Posted January 22, 2009 if you use the link: echo "Hello ".$_GET['var1'];echo $_GET['var2']; if you use the form: echo "Hello ".$_POST['var1'];echo $_POST['var2']; Link to comment Share on other sites More sharing options...
jawad hamzah Posted January 22, 2009 Author Share Posted January 22, 2009 thanksI know that but i want to get var2 the value of input text in the form , how ??if i ernter any value in input text like ( Jon ) and click the link then in page2.php print :hello : Jon .how ?? Link to comment Share on other sites More sharing options...
Lulzim Posted January 22, 2009 Share Posted January 22, 2009 you have to give a name to the input field, like <input type='text' name='mytext'> then get the value from $_POST['mytext']also you have to add a input submit, clicking the link won't submit the form Link to comment Share on other sites More sharing options...
jeffman Posted January 22, 2009 Share Posted January 22, 2009 If I understand you correctly, this should work: <a href='page2.php?var1=hello&var2=' onclick="this.href+=document.getElementById('mytext').value">Go To Page2</a> Link to comment Share on other sites More sharing options...
jawad hamzah Posted January 24, 2009 Author Share Posted January 24, 2009 Yes , that i want .Thanks . Link to comment Share on other sites More sharing options...
jawad hamzah Posted January 27, 2009 Author Share Posted January 27, 2009 above i learn how i but text value in my varible by this code <a href='page2.php?var1=hello&var2=' onclick="this.href+=document.getElementById('mytext').value">Go To Page2</a>but i tray to put many values from my form's input but ???then i want like this :If i have three textbox in my form and i want to show it's value in three varible like this :<form action='page1.php' method='post'><input type='text' id='mytext1'><input type='text' id='mytext2'><input type='text' id='mytext3'><a href='page2.php?var1=(value of text1)&var2=(value of text2)&var3=(value of text3)'>Go To Page2</a></form>How i make it please ?? Link to comment Share on other sites More sharing options...
justsomeguy Posted January 27, 2009 Share Posted January 27, 2009 Use a submit button instead of a link. You can format the button to make it look like a link, but just use a regular submit button. This is exactly what forms and submit buttons are for, there's no reason to try and reinvent the wheel. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.