PDA

View Full Version : innerhtml Vs. PHP



jcdevelopment
Jan 29th, 2009, 04:18 PM
Correct me if i am wrong in comparing the two but i was just curious.

What are the advantages of using innerhtml over PHP echo to write out a string?

Or what are the advantages over using PHP echo over innerhtml ?

I was wondering which has its own advantage? Thanks for any input or corrections!

oesxyl
Jan 29th, 2009, 04:26 PM
Correct me if i am wrong in comparing the two but i was just curious.

What are the advantages of using innerhtml over PHP echo to write out a string?

Or what are the advantages over using PHP echo over innerhtml ?

I was wondering which has its own advantage? Thanks for any input or corrections!
echo is executed on the server side, innerHTML is on client side so all depend of your design. I would use innerHTML, or similar, when I want to transform the page already loaded by client or process a ajax response and output to the client.
Everything else echo/print.

best regards

Apostropartheid
Jan 29th, 2009, 05:33 PM
Echo always works. *shrugs*. You should always use echo when a dynamic change is not required (i.e. it's printed at runtime.)

primefalcon
Jan 30th, 2009, 01:09 AM
Only use innerHTML if you need to modify a page after it has already loaded. The problem with JavaScript is that it isn't indexable by search engines. PHP does not suffer from this since it just outputs HTML to the browser.

Alferd
Jan 30th, 2009, 01:40 PM
Javascript form validation is by no means trivial, and depends almost entirely on your definition of "valid" for each field. Most methods, however, follow a similar structure:

1. Retrieve the element(s) to be validated.
2. Pass the value of the element to a function that will return true/false if the value is "valid".
3. Repeat as desired until a decision is made whether the form itself is "valid".

W3Schools has a decent conceptual overview.