Page 1 of 1
Put a value from PHP to INPUT Text?
Posted: Tue Jun 16, 2009 11:05 pm
by jpor
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.
Re: Put a value from PHP to INPUT Text?
Posted: Tue Jun 16, 2009 11:07 pm
by RiMMER
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?
Re: Put a value from PHP to INPUT Text?
Posted: Wed Jun 17, 2009 7:28 am
by jpor
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.
Re: Put a value from PHP to INPUT Text?
Posted: Wed Jun 17, 2009 8:38 am
by papa
Sure you have the correct JS syntax?
Re: Put a value from PHP to INPUT Text?
Posted: Wed Jun 17, 2009 9:44 am
by juma929
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
Re: Put a value from PHP to INPUT Text?
Posted: Wed Jun 17, 2009 1:23 pm
by McInfo
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.