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

Posted by d on 09/28/91 11:41

"Good Man" <heyho@letsgo.com> wrote in message
news:Xns977B721C4FAB1sonicyouth@216.196.97.131...
> "J.O. Aho" <user@example.net> wrote in
> news:46r7pkFchn19U1@individual.net:
>
>
>> I don't really see the point in using javascript at all in this case,
>> you get a more difficulty to figure out bugs.
>>
>> if you use
>>
>> <input type="text" id="firstName" value="<?= $first_name ?>" />
>> <input type="text" id="secondtName" value="<?= $second_name ?>" />
>> <input type="text" id="lastName" value="<?= $last_name ?>" />
>>
>> You either have a value set of the variables $first_name,
>> $second_name, $last_name and so on (I know, I added the two last
>> ones).
>>
>> If a value isn't set, then the box will be empty and it's just to add
>> the values manually.
>
> The only point would be saving me programming time. On a page with 50+
> form-fields, I can save lot of time by writing a PHP loop that writes an
> HTML call to a javscript function instead of going to each form field and
> entering the value="<?= $first_name ?>" stuff...

May I suggest learning templates? They exist for just this sort of thing.
They take the edge off writing repetative pages. Either write your own
templating toolkit (better) or get one off the shelf.

Personally, I use javascript when it's a good idea to, and not when it isn't
:) For instance: a registration page. I'll use php to write the values
into the text fields (name, address, email, etc.), and a tiny line of
javascript to set the country in the drop-down (of 200+ entries). Storing
the list dynamically, and looping through it to set the right one to
"selected", is a lot more work than just getting the browser to do it.
Remember the browser has native code for manipulating HTML objects, whereas
PHP has native code for outputting HTML, and that's about it ;)

dave

 

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

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