2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by phpbeginner
0

i will make my question more clear..

<form name='a' action='$PHP_SELF'>
<input type='hidden' name='type' value='text'>

<select name='product' onChange='document.a.submit();'>
<option value='' selected>products</option>
.....
.....
</select>
if(product == book) {
country = "abc";
}

<select name='region' onChange='document.a.submit();'>
<option value='' selected>Country</option>
.....
.....
</select>


</from>

say the url is www.someaddress.com?country=asd

in this, when the product is book, the url will not get updated with the country given. so is there a method to update the url with the new country "abc" when product book is selected... ie. www.someaddress.com?country=abc

thanks!

0

If you are submitting the form to the same page, I think you can get the country value in the page itself, by

<?php
echo $_POST['region'];
?>

But if you still want the to change the url then you have to call a JavaScript function in which submit the form by

<script type="text/javascript">
function submitForm{
window.location='pageName.php?y='+document.a.region.value;
}
</script>
0

thanks for the reply...
but the problem is not solved..

this is useful if there is some event happens such as onChange, onClick etc. here what happens is

eg: category book have countries - aa,bb,cc
and category pen have countries - xx,yy,zz

if i select book, and country cc, the url works fine since its onChange event.
But if i select pen, the coutries are totally different and i write in the code country=xx (which i points to first element of array). In the select box, the new set of coutries will get updated, but in url the country=cc instead of country=xx. Again if i select yy/zz the url will be fine with correct updates. So i need to update the first time when there is a switch in categories.

hope you understand the issue.

thanks!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.