Page 1 of 1

PHP echo information in a form field?

Posted: Tue Apr 07, 2009 9:05 pm
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!

Re: PHP echo information in a form field?

Posted: Tue Apr 07, 2009 10:21 pm
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.

Re: PHP echo information in a form field?

Posted: Wed Apr 08, 2009 2:59 am
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.