You are here: Getting values into a form: PHP (Server) or Javascript (Client) Side? « All PHP « IT news, forums, messages
Getting values into a form: PHP (Server) or Javascript (Client) Side?

Posted by Good Man on 09/28/65 11:41

Hi

This is sort of a weird question, perhaps a bit off-topic...

I am on the 'edit' screen of a web form, and I have a bunch of variables
coming from a database that need to be placed into the form. In the
past, I have been using PHP to pre-populate each field, something like

<input type="text" id="firstName" value="<?= $first_name ?>" />

But, since my "add" and "edit" screens are virtually the same, I'm
thinking about using PHP to dynamically create "onload" javascript
events that use a custom function... essentially something along the
lines of

onload = "setForm('firstName','<?= $first_name ?>');"

So, option one hard-codes the form-field value directly into the HTML.
Option two uses javascript to populate the fields.

This is a specific web application targeted to a finite audience who
will be using javascript-enabled browsers. At this point, I'm thinking
of going with the second option(javascript based), because I won't have
to scroll down to each form-field tag in my document and add the "value"
parameter (read: time saver).... the only drawback I can see is CPU Power
I guess... Or is that a ridiculous concern? What about using Javascript
to populate 100 fields?

Most importantly, do I need to worry about client-side interruptions that
can prevent the form from being populated (other than turning javascript
off)?

Thoughts appreciated!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация