Re: Reg. Dynamically populate a checkbox



On 08/29/2006 03:01 AM, calms wrote:
Mumia W. wrote:
On 08/29/2006 02:04 AM, calms wrote:
HI,
Hi

First of all im vry new to PHP, i like to retrieve a value from DB,
accordingly i like to display the checkbox, either checked or not.

Now im able to retrieve the value from DB, i can show even show the
checkbox, but i cant make it checked????
[...]
It's a good idea to learn HTML before learning PHP. HTML is a
complicated language with one purpose, and PHP is another
complicated language with a slightly different purpose.
Learning both at the same time can be overwhelming.

The "checked" attribute, in HTML, is used to make a checkbox
checked.

http://www.w3.org/TR/html4/interact/forms.html#checkbox

thks for your reply,

but as you can see i used the 'checked' attribute, still i cant make it. I knw tht i have done some mistake in the echo statement. as follows,

It's difficult to understand what you write. Please spell words completely if you can.


echo "<tr>
<td Class='navText' align='center' class=$c>$event_id</td>
<td class='navText' class=$c>$event_name</td>
<td class='navText' align='center' class=$c><INPUT TYPE=CHECKBOX
NAME='publish' VALUE=1 <?php echo ($event_publish == 1 ? 'CHECKED':
''); ?></td>
<td class='navText' align='center' class=$c><a
href='delete_event.php?event_id=$event_id'>$take_action</a></td></tr>";

kindly correct me...

thks


Within an echo statement, <? php-code ?> does not work. Just output a variable's value:

$event_publish_checked = ($event_publish == 1 ? 'CHECKED' : '');

echo "<tr>
<td Class='navText' align='center' class=$c>$event_id</td>
<td class='navText' class=$c>$event_name</td>
<td class='navText' align='center' class=$c><INPUT TYPE=CHECKBOX
NAME='publish' VALUE=1 $event_publish_checked </td>
<td class='navText' align='center' class=$c><a
href='delete_event.php?event_id=$event_id'>$take_action</a></td></tr>";


.



Relevant Pages

  • Re: multiple row updates in MYSQL using HTML
    ... > if the checkbox is checked incase you are updating most of the records ... >>all to another perl script to perform the update. ... >>I basically need maintenance of one table with unlimited rows containing ... HTML? ...
    (comp.lang.perl)
  • Plain text and html not getting along in net.mail.message
    ... text with html formatted text and set the isBodyHTML = true that I get ... I've a checkbox that if checked sets the IsBodyHTML=true. ... Dim MyMail As MailMessage = New MailMessage ... Dim SMTPMail As SmtpClient = New SmtpClient ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Problem with Javascript in a UserControl
    ... Make a look at the HTML generated by your code and find your checkbox ID. ... fine if I put the UserControl Data directly in my Web Page. ... I am used to seeing this from DataGrids, but not as a regular control on the page. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Adding CssClass property default to custom checkbox wraps with span tag
    ... checkBox server control,correct? ... doesn't 100% identical to the html checkbox input element. ... element inside the ASP.NET checkbox server control, ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: How can I code to get more than One value from checkbox?
    ... > I'm a newbie that just started to learn python, html and etc. ... > html form that consists of about 10 checkbox and a textbox where user ... > %(qtype) in my query statement so that the script will look for the ...
    (comp.lang.python)