tags:

views:

40

answers:

1

I have the following scenario:

A multiple step registration procedure. Let's say it's 4 steps, and each step depends on previous input. This could be solved with or without Javascript.

Without JS: A "proceed"-button is attached to each step With JS: The next part is automatically revealed to the user when previous step is done. (No "proceed"-button exists.

The problem is: How do my template engine know which one to present? With or without proceed buttons? You can not just try to test a JS-block of code to determine if it is enabled before PHP loads the template.

One way I've worked out is the possibility that the initial load of the visit sends an ajax-request to a file on the server which only purpose is to set $_SESSION['JS_ENABLED'] = 1 or something like that.

I don't like this. The HTTP request for that file might very well fail leaving the site in belief that the visitor has JS disabled.

I think I need a new approach. Please enlighten me =)

A: 

You could do somethin like this:

<p>Step ....</p>
<a id="proceed_link" href="no_script_proceed_link.php">Proceed</a>
<script type="text/javascript">
// example with jquery
$.getScript('script/url.js',function(){ 
   $('#proceed_link').hide();
   // other stuff when scripts are available
});
</script>
I'm not sure I follow you. Without testing I assume that would actually display the link until the script actually runs and not hiding it until then?
Anders
well the idea is that you load the basic page and by getting a javascript file thru javascript, so you know javascript is enabled. without loading the script when there is no javascript support. and yes your assumption is correct