Aaron Aaron - 6 days ago 8
PHP Question

How to get a text box value using HREF without POST


http://localhost/check.php?date=textbox1&time=textbox2


<a href="http://localhost/check.php?date=textbox1&time=textbox2" onclick="window.open('http://localhost/check.php?date=textbox1&time=textbox2', 'newwindow', 'width=600, height=600'); return false;"> <i class="glyphicon glyphicon-plus"></i></a>


This is my current code, I would like to transfer textbox 1 and textbox 2 value on a GET method. I tried
document.getElementbyId('date')
.value but no luck.

Thank you.

Answer

I'm not sure what you are trying to do here. From what I understand, you have this...:

<input type="text" id="date"/>
<input type="text" id="time"/>

...and you want to use these textbox values for request parameters. Try this:

function submitDateAndTime() {
  var url = 'http://localhost/check.php?date=';
  url += document.getElementById('date').value;
  url +='&time=';
  url += document.getElementById('time').value;
  // Do whatever you want with the URL here
  // For example, window.open to load in a new window:
  window.open('url');
  // Or use _self if you want to load in the current window
  window.open('url', '_self');
  // Or ajax, etc.

and for HTML:

<a href="javascript:void submitDateAndTime();">Submit</a>
Comments