set textbox value with php

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
jubairarifctg
Forum Newbie
Posts: 1
Joined: Tue Apr 15, 2008 9:47 pm

set textbox value with php

Post by jubairarifctg »

Hi there

I have a textbox in my php page like this

Code: Select all

<li><B>1.</B> planetlab1.cs.uchicago.edu [University of Chicago]:
<br><input type="text" id="radius1" style="width:50px;" title="Type your radius in km" value="0"/>km
Now I have another php function

Code: Select all

function valueInsert($tname, $tdist){
 
echo "<br>From valueInsert<br>";
echo $tname;
 
if ($tname=="planetlab1.cs.uchicago.edu")
        document.getElementById("radius1").value=$tdist;
 
 
}
After searching to mysql, I want to setup a value in my textbox radius1 inside the function valueInsert. However, it is not working. I guess I am making confusion with server end and client end concept. Can anyone help me to get it right. If not php, how can I populate my textbox after searching a data from mysql?
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Re: set textbox value with php

Post by Phoenixheart »

Yes, you're confused between server and client scripts. document.getElementById() etc. is a Javascript function.
You just need to do something like this:

Code: Select all

 
$value = get_data_from_mysql(); // do your mysql stuffs here 
echo '<input type="text" id="radius1" style="width:50px;" title="Type your radius in km" value="' . addslashes($value) . '"/>';
 
Post Reply