Page 1 of 1
PHP Equivalent to .Net .text
Posted: Fri Jul 22, 2005 9:11 pm
by jbcook
I'm a newly .net to PHP convert. Its going great so far, much lighter than .net. In .net, you could use server side code to assign a value to a textbox by using txtName.Text = "value". I know I can pass my PHP variable into a session, then pick it up with Javascript, then use JavaScript to set the value. However, I was wondering if there was a simpler way of accessing form fields without client side JavaScript. Of course, thats why .net is so heavy because its more intuitive. Thanks for the help!
Posted: Fri Jul 22, 2005 9:28 pm
by nielsene
I'm not sure exactly what you're asking, but if you want to simply put a value into a regular text box you can do something like
Code: Select all
echo "<input type=\"text\" name=\"txtName\" value=\"$valueToInsert\" />";
or
Code: Select all
echo "<textarea name=\"txtName\" rows=\"5\" columns=\"60\">$valueToInsert</textarea>\n";
I would be careful with statements like
Of course, thats why .net is so heavy because its more intuitive.
as its not entirely true and liable to start a flamewar. Its also the type of statement that could make some people not want to help you.
Posted: Fri Jul 22, 2005 10:06 pm
by jbcook
Nope, thats not what I'm looking for. I don't think PHP can do it as easily as .Net. Not trying to start a flame war, but I've been a .Net developer for 3 years and only been doing PHP for a couple of months...the advantages of PHP is starting to outway .Net. Don't forget...just 2 months ago I would have been preaching about the wonders of .Net.
Posted: Fri Jul 22, 2005 10:22 pm
by nielsene
Well can you explain what you are trying to do then?
You say you want a replacement for a .net server-side thing, but then talk about JavaScript which is purely client-side. What are you trying to accomplish?
Posted: Fri Jul 22, 2005 11:38 pm
by Revan
I *think* I might know what you mean (whoa, grammar).
<form method="post">
<input type="textbox" name="whatever">
</form>