Hello, I have a perplexing issue going on. I have a simple, two checkbox form for updating two values in my login table. The row type is enum('y','n') so naturally a check box is my preferred way to set the value. Even though the value in the table is set to 'y', the check box in the form is never checked. I check it, click the submit button, and the update occurs in the table but the check box remains unchecked on the form. My code for the form is below. Any idea what I'm missing here?
%26lt;form method=''post'' id=''form4'' action=''%26lt;?php echo KT_escapeAttribute(KT_getFullUri()); ?%26gt;''%26gt;
?%26lt;table cellpadding=''4'' cellspacing=''0''%26gt;
?%26lt;tr%26gt;%26lt;td%26gt;%26lt;input?%26lt;?php if (!(strcmp(KT_escapeAttribute($row_rslogin['show_profile']),''y''))) {echo ''checked'';} ?%26gt; type=''checkbox'' name=''show_profile'' id=''show_profile'' value=''y'' /%26gt;%26lt;/td%26gt;
?%26lt;td%26gt;%26lt;label for=''show_profile''%26gt;Show my profile to other myJoy members.%26lt;/label%26gt;%26lt;/td%26gt;
?%26lt;/tr%26gt;
?%26lt;tr%26gt;
?%26lt;td%26gt;%26lt;input?%26lt;?php if (!(strcmp(KT_escapeAttribute($row_rslogin['get_mail']),''y''))) {echo ''checked'';} ?%26gt; type=''checkbox'' name=''myjoymail_optout'' id=''myjoymail_optout'' value=''y'' /%26gt;%26lt;/td%26gt;
?%26lt;td%26gt;%26lt;label for=''myjoymail_optout''%26gt;Send me myJoy email and notifications.%26lt;/label%26gt;%26lt;/td%26gt;
?%26lt;/tr%26gt;
?%26lt;tr%26gt;
?%26lt;td%26gt;%26lt;/td%26gt;%26lt;td%26gt;%26lt;input type=''submit'' name=''KT_Update3'' id=''KT_Update3'' value=''Save Prefs'' /%26gt;%26lt;/td%26gt;
?%26lt;/tr%26gt;
?%26lt;/table%26gt;
?%26lt;/form%26gt;
Check boxes not retaining their correct...Hi,
Well I took your code and changed it to:
%26lt;?php if (!(strcmp(''y'',''y''))) {echo ''checked'';} ?%26gt;
Getting rid of the KT_escapeAttribute() and manually entered the y. It worked fine. And even with the KT_escapeAttribute() it will probably work fine. Have you doubled checked that the database is not storing a Captial Y or a 0 or 1? Your using varchar correct, not char?
Check boxes not retaining their correct...Thanks Albert for the suggestion. It still doesn't work. The column type was ENUM, and it stores either a 'y' or an 'n'. I did as you suggested with the code and now instead of the boxes being unchecked all the time, they are checked all the time, no matter what the value in the database.
I even changed the column type to VARCHAR with a length of 1, which didn't work. Any other options for me, or do I need to switch to the dreaded pop-up menu for my preferences?
Hi,
I only edited your code to make sure it was working correctly, not for you to actually use that code as yes it will make the box checked all the time.
So since you know the code is working fine you need to find the problem else where. Maybe echo the values before the checkbox and make sure the values are correct. If it is i'm not really sure what it could be.
No comments:
Post a Comment