Forum Moderators: open

Message Too Old, No Replies

Allowing users with javascript disabled

Ok, but how?

         

tata668

3:14 am on Jul 21, 2005 (gmt 0)

10+ Year Member



Let's say I have to ask informations about the user when he registers.

He selects his country.
If his country is "United States", I want to populate a new select control to let him choose a state. How can I do that without javascript?
Even if I do a roundtrip to the server to populate the states control, I can't submit the form on the "onChange()" event of the countries control without javascript!

Should I ask the user to choose his country, then press a button to submit the form and populate the states control on the server? Don't you think this is kind of ugly?

Any thoughts?

Krapulator

4:00 am on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have the State select list showing up by default. Then use JS to immediately hide it. Then use js to show it again if the user chooses the United States in the country list.

tata668

11:46 am on Jul 21, 2005 (gmt 0)

10+ Year Member



The problem is if the user chooses another country, I want to populate the "states" control with different values.

For example, if he select "Canada", I will display "Alberta", "Ontario", etc.

rocknbil

3:50 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you don't want to use JS you'll have to do a server-side query to repopulate the page with the new lists.

<form action="your_script">
Begin by selecting your country:
<select name="country">
<option value="US">US</option>
<option value="AL">Algeria</option>
....
</select>
<input type="submit" value="Continue">
</form>

john_k

4:00 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could use Krapulator's suggestion, but on the PREVIOUS page. So the GET/POST request that is loading your page would tell the server what to do. That is, if the request indicates no javascript, then load a different version of the select list - containing every country-state/province combo. If the request indicates javascript is available, then tailor the page the way you have described.

tata668

4:12 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



But I don't have a previous page...

This is my point: to be able to register a user with no javascript, I can't ask his informations on one page only. I have to ask him the country first, then ask him to submit the page to go on a new page where I'll ask him for the state/province. I think this solution is not really nice.

I'm seriously thinking about only supporting javascript enabled client! :(

Trace

4:52 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



Could this work?

Load your select with all possible options, then use JS to hide the ones that don't belong.

This way, if your user does not have JS enabled, it will simply list everything in the select.

Does that make any sense?

tata668

5:08 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



This is not a bad idea but it's not really nice IMO. The user will have to decide by himself which state/province is legal for the selected country...

Also, if there are 50 countries containing "regions", the dropdown could be really long!

Trace

1:21 pm on Jul 22, 2005 (gmt 0)

10+ Year Member



I agree that it's not the prettiest solution, but you're talking about develloping something for what? less than 1% of the users that will use this app?

I really don't see how you can do everything you want with out page reloads or js.