PDA

View Full Version : How would you code this...??



sportious
07-27-2005, 01:10 PM
:rolleyes: I am trying to establish a way for site visitors to be able to select what they want and as they click on 'go', it takes them there...

so far, I have learned the single-selection code, and would like to expend to something that provides multiple-selection code.

example of what I am speaking about....

"Where do you live?" - Here the visitiors click on "state" then select "county" then select "city".... after their selections have been made, they click on 'go', then it takes them to their town, on the site!

So, if you can help, please do!

Greatly appreciated!

JL :)

Twey
07-27-2005, 05:17 PM
<select id="state">
<option value="mi">Michigan</option>
<option value="ca">California</option><!-- Californya, Californyaaa... woooaah, Californya... -->
</state>

<select id="county">
<!-- I don't know any American counties. -->
<option value="hearts">Heartfordshire</option>
<option value="wsus">West Sussex</option>
</select>

<select id="city">
<option value="ny">New York</option>
<option value="la">Los Angeles</option>
</select>

<button onclick="window.location.href='/' + document.getElementById('state').value + '/' + document.getElementById('county').value + '/' + document.getElementById('city').value + '.htm';">Go!</button>

For example, if the user selected "Michigan," "Heartfordshire," and "New York," this would take them to http://www.yoursite.com/mi/hearts/ny.htm.

Sorry my American geography's a bit whacked, I'm English and it was never my best subject anyway :p

sportious
08-04-2005, 02:39 PM
<select id="state">
<option value="mi">Michigan</option>
<option value="ca">California</option><!-- Californya, Californyaaa... woooaah, Californya... -->
</state>

<select id="county">
<!-- I don't know any American counties. -->
<option value="hearts">Heartfordshire</option>
<option value="wsus">West Sussex</option>
</select>

<select id="city">
<option value="ny">New York</option>
<option value="la">Los Angeles</option>
</select>

<button onclick="window.location.href='/' + document.getElementById('state').value + '/' + document.getElementById('county').value + '/' + document.getElementById('city').value + '.htm';">Go!</button>

For example, if the user selected "Michigan," "Heartfordshire," and "New York," this would take them to http://www.yoursite.com/mi/hearts/ny.htm.

Sorry my American geography's a bit whacked, I'm English and it was never my best subject anyway :p

towards the end of the code, you have specified '.htm'.... For this, do I have to type the URL to complete the coding?

thanks!

JL

sportious
08-04-2005, 02:43 PM
I read thru it, and answered my own question!

Thank you though for your great help!

ps. you'd said that English is not your best subject (or something like that), but HTML is definitely something of your better interest!

JL

Twey
08-04-2005, 02:52 PM
Nonono, "Geography" was the last noun, hence referred to by the pronoun "it." "English" was used as an adjective. My English is fine; it's my geography that suffers :p
And I'm not nearly as good at HTML as, say, Mike :p

sportious
08-23-2005, 07:25 PM
thank you for helping thus far....

how would you code it if i'd like to display in the 'option box' state, prior to one clicking and selecting the city/state???

in other words, i would like it to appear 'select state' in the box, then as one clicks on the down arrow, the valid states will appear for selection.

please help!

Twey
08-24-2005, 11:29 AM
Ooh - I just spotted a typo.

<select id="state">
<option value="mi">Michigan</option>
<option value="ca">California</option><!-- Californya, Californyaaa... woooaah, Californya... -->
</state>
It should be </select>, not </state>. Surprised no-one picked up on that!



<script type="text/javascript">
function go() {
var s = document.getElementById('state').value;
var c = document.getElementById('county').value;
var i = document.getElementById('city').value;
if ((s === "NONE") || (c === "NONE") || (i === "NONE")) return false;
window.location.href='/' + s + '/' + c + '/' + i + '.htm';
return true;
}
</script>

<select id="state">
<option value="NONE">Select State...</option>
<option value="mi">Michigan</option>
<option value="ca">California</option>
</select>
<select id="county">
<!-- I don't know any American counties. -->
<option value="NONE">Select County...</option>
<option value="hearts">Heartfordshire</option>
<option value="wsus">West Sussex</option>
</select>
<select id="city">
<option value="NONE">Select City...</option>
<option value="ny">New York</option>
<option value="la">Los Angeles</option>
</select>
<button onclick="go();">Go!</button>

sportious
08-31-2005, 03:05 AM
I am guessing this coding is going to appear like I asked... I will try it... thanks!