Help with a line of code

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Help with a line of code

Post by nigma »

Hey, I am donering why this line of code:

echo("Apreciated person #$c: <input type=\"text\" name=fname$c value={$_POST['fname'.$c]}><br><br>");

prints only the first word what was entered in field fname on the previous input box?

Anyone know how to correct this problem so that this input box will display all text that was written in the previous input box?

Thanks for all help and advice provided.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to put quotes around your value attribute (or better yet all attributes) and then this won't happen:

Code: Select all

echo 'Apreciated person #'.$c.': <input type="text" name="fname'.$c.'" value="'.$_POST['fname'.$c].'" /><br /><br />';
If you don't put those double quotes in you get something like this produced:

Code: Select all

&lt;input type="text" name=fname1 value=something or other&gt;
and the browser has no idea that ' or other' have anything to do with the value, whereas it does if you have:

Code: Select all

&lt;input type="text" name="fname1" value="something or other"&gt;
Mac
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

That didn't work either. I have asked about this before and have recieved serveral ideas but all didn't work. So I dont know what is going on.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you tried just using of code like:

Code: Select all

<input type="text" name="fname1" value="something or other">
with all the values hardcoded in to see if that works?
Mac
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Hmm.. I will check that out. If it works does that mean I have a problem with a setting in like php.ini or another configuration file?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If it works it may be that there is an issue in the code that posts the variables to this page.

Mac
net7
Forum Commoner
Posts: 31
Joined: Wed Mar 12, 2003 1:27 pm

Post by net7 »

echo "Apreciated person #{$c}: <input type=\"text\" name=fname{$c} value={$_POST['fname{$c}']}><br><br>";
Post Reply