/    Sign up×
Community /Pin to ProfileBookmark

User Events in PHP

I think maybe this is a dumb question, and I think the answer is probably No Way Buddy, but here goes:

I was building most of my pages with a couple of javascripts that just wrote the generic formatting, etc, to each page. A member here advised me that 10% of browsers in use don’t have javascript enabled, so I got busy and switched the whole thing over to PHP, so I wouldn’t have to depend on client-side processing to format the pages. It was easy and works great.

I have a few vestiges of javascript left — a couple of HTML forms in which an input might fill in automatically, etc. For example, onblur for a group of inputs might call a function that adds up how many of that group have any text in them, and increments another input.

Is there a way to use an HTML user event to force the page to repaint, using PHP only? Or are my PHP options limited to the ACTION attribute of the form?

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@bokehSep 15.2005 — Without client side scripting your only option to update something is to reload the page.

I personally used to be anti javascript for the reason you mention but I'm coming around now. I think the secret is the page must work with or without javascript but that doesn't mean it has to work in an identical fashion.
Copy linkTweet thisAlerts:
@SheldonSep 15.2005 — Yes i agree with Bokeh, I used to use javascript alot, then not at all, now as he said, i use it where you would realise that i hasnt been used if it insnt enabled.

Try php validation, you can use php or javascript for population feilds either depending on if you refresh the page.

I think i have just said exactly the same as bokeh, just to back up his theory i think!

?
Copy linkTweet thisAlerts:
@strBeanauthorSep 15.2005 — That's a good point, that it needs to work, somehow, when the browser doesn't execute the js.

Thanks for answering my question.
Copy linkTweet thisAlerts:
@bokehSep 15.2005 — What I am really saying is that people with javascript disabled should not realize anything is missing even though the page doesn't function the same.
Copy linkTweet thisAlerts:
@strBeanauthorSep 15.2005 — So, if I have a js that does a calculation and fills in an input, I also need a PHP validation routine that reminds the non-js user to do the calculation and fill it in themselves...
Copy linkTweet thisAlerts:
@bokehSep 15.2005 — Let's take that as an example. Let's say they fill in some fields and then click a button that is called 'calculate', if javascript is enabled the calulation is done on the client's machine but if javascript is disabled the data is submitted to the server for calculation.
Copy linkTweet thisAlerts:
@strBeanauthorSep 15.2005 — Right, that's a good example. I can imagine a PHP file having a pretty complicated switch statement in it, if there are lots of these possibilities.
Copy linkTweet thisAlerts:
@SheldonSep 15.2005 — deffinitly, its not to hard to code in php either, i think easier than js sometimes, but then im not js buff
Copy linkTweet thisAlerts:
@SpectreReturnsSep 16.2005 — JS has some stupid syntax as well as just throwing off generic errors if you name your variable wrong.
Copy linkTweet thisAlerts:
@bokehSep 19.2005 — Right, that's a good example. I can imagine a PHP file having a pretty complicated switch statement in it, if there are lots of these possibilities.[/QUOTE]What gives you that idea? The page can be very simple and still use both PHP and Javascript to do the same jobs dependant on the way the client's browser is set. [URL=http://bokehman.com/javascript_and_php]Here is an example[/URL] of PHP and Javascript doing the same job. In my opinion, in this example only a fool would prefer the PHP version over the Javascript version.
×

Success!

Help @strBean spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...