PHP echo information in a form field?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jessn
Forum Newbie
Posts: 2
Joined: Tue Apr 07, 2009 9:04 pm

PHP echo information in a form field?

Post by jessn »

I'm hoping you all can help me with something. I have a form for the user to fill out with some information. What I would like is when they fill in certain fields, the information that's entered there will be printed, or echoed, in the sidebar. So for example say they fill out a field called "domain url". When they fill that out the url they enter will show up in the sidebar.

Sounds like a PHP thing but I'm not sure where to start. Would appreciate any advice! Thank you!
jessn
Forum Newbie
Posts: 2
Joined: Tue Apr 07, 2009 9:04 pm

Re: PHP echo information in a form field?

Post by jessn »

As they enter it. I don't care about the information being saved in any way, just want to use it to kind of summarize the info they've put in.
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: PHP echo information in a form field?

Post by watson516 »

This would be javascript, not php. Php is run on the server and therefore would not be able to accomplish this. I am pretty terrible at javascript but something like this might work

Code: Select all

<script type="text/javascript">
function printSum(field) {
    document.getElementById(field+'-sum').innerHTML = document.getElementById(field).value
}
</script>
...
<input type="text" id="domain" onchange="printSum('domain')" />
<div id="domain-sum"></div>
 
As stated above, Im not the greatest with javascript but I just tested this code and it seems to work fine.
Post Reply