Forum Moderators: coopster

Message Too Old, No Replies

Help about select

         

orion_rus

3:11 pm on Jan 2, 2005 (gmt 0)

10+ Year Member



Hello world, i have a site where i need to select country and city. If i use javascript it's ok then. But if somebody didn't have a script i think i need to make a [noscript] tags, what's why i need to make following: then somebody choose country, i need to reload page with citys parameters. Can somebody help me to do this without <script> i don't know how to reload page if somebody change state of select?

dreamcatcher

5:57 pm on Jan 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi orion_rus,

Javascripts onChange function is what you are looking for I think. Something like this will work:


<select name="select" onChange="location=this.options[this.selectedIndex].value">
<option value="index.php?country=England">England</option>
<option value="index.php?country=hongkong">Hong Kong</option>
<option value="index.php?country=us">US</option>
</select>

When your page reloads, use the $_GET variable set by the script.

Maybe that helps?

dc

mcibor

9:47 pm on Jan 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dreamcatcher!

He said without Javascript!
You can't reload the page automaticaly without javascript. What you can try is to make <option> links, eg:

<option><a href="i.php?o=England">England</a></option>
<option><a href="i.php?o=Hongong">Hong Kong</a></option>
<option><a href="i.php?o=USA">USA</a></option>

but I'm not sure if this will validate.

You can always add a button <input type="submit"> and get the value in php with $_GET.

dreamcatcher

11:14 pm on Jan 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



He said without Javascript!

hee hee! Well, he also said "Can somebody help me to do this without <script>", which technically what I posted is.

:)

mcibor

9:53 am on Jan 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



True!
:D

But I checked with validator and it isn't possible to put <a> in between <option> and </option>.
Therefore the only solution is to place a submit button. I'm sorry it didn't work!

Best regards
Michal Cibor

orion_rus

10:27 am on Jan 3, 2005 (gmt 0)

10+ Year Member



No problem) it's ok)
I'm make it with javascript, i often see some sites where one select then choosen fill another select. I think it could be done without javascript, but now i see it isn't. I need to make search for country and city. And i don't know how it could be linked without javascript)

mcibor

2:34 pm on Jan 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Without any javascript there are two ways of doing this:

1st way:
make column with countries, that is linked
<p><a href=index.html?country=England>England</a><br>
<a href=index.html?country=Holand>Holand</a><br>
<a href=index.html?country=USA>USA</a><br>
<a href=index.html?country=RPA>RPA</a></p>

2nd way:
make a form and a button to submit:
<form action="index.html" method="POST">
<select name="country" id="country">
<option>England</option>
<option>Holand</option>
<option>USA</option>
<option>RPA</option>
</select></form>

in 1st way index.html you have the country in variable $_GET["country"]
in 2nd way you have it in the $_POST["country"] however not straight forward, only by a number of selection.

With javascript there's no problem I presume!

Ask yourself one question: Is it worth bothering?

Best regards
Michal Cibor