hi all,

is there a method to change the url variable?

eg: from www.someaddress.com?value=value1 to
www.someaddress.com?value=value2?

Recommended Answers

All 3 Replies

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!

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>

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.