Page 1 of 1
Problem with Default value in text box using PHP
Posted: Fri Jul 11, 2003 3:03 pm
by szms
I am trying to keep a default text in a text box. But if I try to use couple of words having spase in between it just only taking the first word. I want to show the couple of words in the text box. How can I do that?
Here is my code...... I am passing the sentence through $Name
$Name = "Hello World";
But it's unly showing "Hello" in the text box.
<input type="text" name="Domain_Name[]" value = <?php print "$Name";?> size = "30">
Re: Problem with Default value in text box using PHP
Posted: Fri Jul 11, 2003 3:07 pm
by nielsene
[Mod's please move to -Normal]
szms wrote:I am trying to keep a default text in a text box. But if I try to use couple of words having spase in between it just only taking the first word. I want to show the couple of words in the text box. How can I do that?
Here is my code...... I am passing the sentence through $Name
$Name = "Hello World";
But it's unly showing "Hello" in the text box.
<input type="text" name="Domain_Name[]" value = <?php print "$Name";?> size = "30">
You are missing the quotes around the value try
Code: Select all
<input type="text" name="Domain_nameї]" value = "<?php echo "$Name";?>" size ="30">
(I like echo better than print, but there is really no difference....) However either print or echo do not add quotes around the string, unless you manually add them. I added them to the raw HTML. If you wanted to add them to the string, you would do
<?php echo ""$Name"";?>
The " tells PHP to actually print a quote, not to end the current string.