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
jpor
Forum Newbie
Posts: 3 Joined: Tue Jun 16, 2009 10:56 pm
Post
by jpor » Tue Jun 16, 2009 11:05 pm
I have a INPUT Text and I give it, through PHP, values depending on the research I do to a database.
Something like that:
Code: Select all
...
<input name="erro" id="erro" value="">
...
<?php
...
echo "document.getElementById('erro').value='Dados Correctos';";
...
?>
But not work.
RiMMER
Forum Newbie
Posts: 3 Joined: Tue Jun 16, 2009 10:29 pm
Post
by RiMMER » Tue Jun 16, 2009 11:07 pm
I don't get what you want to do.
Do you want to take data from SQL and put it into value="" inside the input tag?
jpor
Forum Newbie
Posts: 3 Joined: Tue Jun 16, 2009 10:56 pm
Post
by jpor » Wed Jun 17, 2009 7:28 am
RiMMER wrote: I don't get what you want to do.
Do you want to take data from SQL and put it into value="" inside the input tag?
I have the Input Text with a value. With PHP, I do the SQL Query, and, depending this Query, I modify value of the Input Text and show again this Input.
papa
Forum Regular
Posts: 958 Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm
Post
by papa » Wed Jun 17, 2009 8:38 am
Sure you have the correct JS syntax?
juma929
Forum Commoner
Posts: 72 Joined: Wed Jun 17, 2009 9:41 am
Post
by juma929 » Wed Jun 17, 2009 9:44 am
Hello,
I dont fully understand either what you are trying to achieve...
Putting a value into a text entry box...
<?php
$someValue = "test";
echo '<input type="text" value="' . $someValue . '" />';
?>
Thanks,
Justin
McInfo
DevNet Resident
Posts: 1532 Joined: Wed Apr 01, 2009 1:31 pm
Post
by McInfo » Wed Jun 17, 2009 1:23 pm
You can fill an input using Javascript, but that would not be my first choice.
Code: Select all
<?php
$value = 'abcdefg';
?>
<p>Filled by Javascript : <input type="text" id="txtExample" value="" /></p>
<script type="text/javascript">
document.getElementById('txtExample').value = '<?php echo $value; ?>';
</script>
<p>Filled by PHP : <input type="text" value="<?php echo $value; ?>" /></p>
Edit: This post was recovered from search engine cache.