I am trying to submit a date range which is populated correctly in 2 input's. How would I go about refreshing the page so I can use GET variables with those 2 date ranges? Here is what I have so far. It's in php but it's just echoing. Thanks echo "Start date: <input type='text' id='datepickerstart'>"; echo "End Date: <input type='text' id='datepickerend'>"; echo "Submit : <input type='submit' id='submitdate' name='test' value='Submit' onSubmit=\"document.location='main.php?page=$page&OWNER=$OWNER&CONTROL_ID=$CONTROL_ID&STATUS=$STATUS&START_DATE='+document.getElementById('datepickerstart').value';&END_DATE='+document.getElementById('datepickerend').value;'\">"; echo "</form>"; PHP:
Since your asking for this in the JS forum my suggestion is that you use AJAX to call in your PHP file that does the submitting.
I figured it out. Quick and dirty but works. echo "<input type='button' id='submitdate' name='test' value='Submit' onClick=\"document.location='main.php?page=$page&OWNER=$OWNER&CONTROL_ID=$CONTROL_ID&STATUS=$STATUS&START_DATE='+document.getElementById('datepickerstart').value+'&END_DATE='+document.getElementById('datepickerend').value;\">"; Code (markup):
Given the fields presented, my advice is to swing an axe at the javascript nonsense -- but again if you can't make your form work without scripting FIRST, you have no business adding scripting to it.
I'd like to hear a better alternative of passing get variables from 2 input boxes without using javascript. Not tryning to be rude, just trying to learn.
Pretty simple to not use scripting -- that's what ACTION and INPUT[hidden] are for. I set it to use isset so that if that getDATA exists when the form is sent, they are plugged in for values. (which I think is what you were actually asking...) echo ' <form action="main.php" method="get"> <fieldset> <label for="datePickerStart">Start date:</label> <input type="text" id="datePickerStart" name="START_DATE"',( isset($_GET['START_DATE']) ? ' value="'.$_GET['START_DATE'].'"' : '' ),' /> <br /> <label for="datePickerEnd">End Date:</label> <input type="text" id="datePickerEnd" name="END_DATE"',( isset($_GET['END_DATE']) ? ' value="'.$_GET['END_DATE'].'"' : '' ),' /> <br /> <input type="submit" value="Submit" /> <input type="hidden" name="page" value="',$page,'" /> <input type="hidden" name="OWNER" value="',$OWNER,'" /> <input type="hidden" name="CONTROL_ID" value ="',$CONTROL_ID,'" /> <input type="hidden" name="STATUS" value="',$STATUS,'" /> </fieldset> </form>'; Code (markup): Functionally identical to your initial post, no javascript needed.... also helps to not say echo a dozen times when you don't have to.
BTW -- where did you get the idea you needed to use javascript for what you were doing in the first place? Literally that was some genuine bizzaroland code.