Jump to content

place check in checkbox


wkilc

Recommended Posts

Greetings once again,

 

My script retrieves variables from a database and pre-populates a form:

<input type="text"" name="First" value="<?php echo stripslashes($row['First']); ?>" >

 

Simple to do with text fields, but not as simple for checkboxes:

<input type="checkbox" name="Subject" size="27" value="Math"  checked>

 

In the past I've used JavaScript to place a check in a checkbox, based on the value in the database.  Can anyone show me a simple way to use PHP to place the check if the variable found in the database is in fact "Math"; but leave it it unchecked if the Subject value is empty?

 

As always, thank you!

 

~Wayne

Link to comment
https://forums.phpfreaks.com/topic/210508-place-check-in-checkbox/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.