php - Javascript location.href doesnt redirect
152
My problem is, that thelocation.href
doesn't redirect me to the page that i want. What it does, that the page just reloads.
I tried with button, and withoutpreventdefault()
, but still the same problems.
<script type="text/javascript">
$(document).ready(function(e)
{
$('#submitButton').click(function(e)
{
e.preventDefault();
var iro = $('#iro').val();
var date_start = $('#date_start').val();
var date_end = $('#date_end').val();
location.href = "https://site.hu/cms/uj-kifizetes.php?iro="+iro+"&date_start="+date_start+"&date_end="+date_end+"&lekerdezes=1";
});
});
</script>
<select name="iro" id="iro" >
<?php
$ertek = isset($_POST["iro"]) ? $_POST["iro"] : '' ;
$get_irok = mysqli_query($kapcs, "SELECT iro_id, iro_nev FROM iro WHERE iro_status = 1 ORDER BY iro_nev ASC");
if(mysqli_num_rows($get_irok) > 0 )
{
while($irok = mysqli_fetch_assoc($get_irok))
{
$selected = $ertek == $irok['iro_id'] ? ' selected echo '<option ' . $selected . ' value="'.$irok['iro_id'].'">'.$irok['iro_nev'].'</option>';
}
}
?>
</select>
<td >
<input autocomplete="off" type="text" name="date_start" id="date_start" required value="<?php if(isset($_POST['date_start'])) { echo $_POST['date_start'];} ?>" />
</td>
<td >
<input autocomplete="off" type="text" name="date_end" id="date_end" required value="<?php if(isset($_POST['date_end'])) { echo $_POST['date_end'];} ?>" />
</td>
<td ><button name="submitButton" id="submitButton" type="submit">Lekérdezés</button></td>
Answer
Solution:
Try location.replace
Answer
Solution:
change this line
to this
everything will be fine.