Re: [WSG] Javascript to change pages web standards question

2008-07-22 Thread Breton Slivka
Though really I'm not sure why you need javascript at all for this
particular application. It would be much easier to just ditch the
javascript, and code straight standards compliance. You would lose
nothing, since the javascript you're proposing adds nothing. (unless
I'm misunderstanding, you're using javascript to replicate the
functionality of a link? Why?) This is coming from someone who loves
javascript. Nevertheless, here's how I'd do it:

modify the php script to take a url ? parameter called something like
ahah.  When the parameter is not present, render the whole page,
with the template and everything, along with the appropriate content
from the provided page number. When ahah is set to true, render the
content without the template, for the benefit of the javascript.

Code the javascript so it attaches the appropriate javascript function
call to the onclick of the next page link, and remember to return
false from that function to suppress the natural link behavior. In the
function call the javascript is to pass the ahah parameter set to
true when it retrieves the results of the php script. Then the php
script would render without the template, in a format that you can
easily insert into the dom of the current page. Then use a JS library
called Really Simple History to push in a new history state for that
state change. That way you're not breaking the back button or the
bookmark button. Remember also to code your javascript to save its
state in a hash, that is the part of the URL that comes after #,
which is accessable from window.location.hash. Really Simple History
will probably help you do that.




On Wed, Jul 23, 2008 at 7:27 AM, Michael Horowitz
[EMAIL PROTECTED] wrote:
 So here is a question. Was recently fixing some errors on a site I took
 over.  We have a page that produces a list of accounts and limits it to x
 number of people per page.  Then we have another form element that chooses
 which page of data we view.  Javascript is used so when we change the
 element from page 1 to page 2 it calls a php script that does a new query
 for the next x number of people and displays the results on that page.  In
 this case its an intranet app so I know everyone will have a mouse and
 javascript enabled but how would you code if you wanted to go to web
 standards and have a fallback.

 --
 Michael Horowitz
 Your Computer Consultant
 http://yourcomputerconsultant.com
 561-394-9079



 ***
 List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
 Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
 Help: [EMAIL PROTECTED]
 ***




***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***



Re: [WSG] Javascript to change pages web standards question

2008-07-22 Thread Breton Slivka
Oops, I missed the bit about the form element. In that case,
everything I just said, except add a Submit button to your original
form element, and an action set to the path of your php script, and
the method set to get, the name of your paging element set to match
the name of the parameter that the PHP script accepts, and the values
of the parameters set to match the values the script accepts. with the
javascript, you can remove the submit button, and attach your function
to the on change.


Or you could ditch the javascript and the form element and just use A
tags for your page interlinking.


***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***