Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Setting a checkbox as "on" by default (https://www.warriorforum.com/programming/330897-setting-checkbox-default.html)

davidmeeonline 11th February 2011 08:03 PM

Setting a checkbox as "on" by default
 
Hi Warriors

I am trying to turn a checkbox on by default, so that everytime I create a new post in wordpress, it is automatically enabled. The bit of offending code is

<div style='display: none;' class='edit_stock'>
";
echo "<p><strong class='wpsc_error'>" .__('Note: If you are using variations please ensure you populate the stock under "Variation Control"', 'wpsc')."</strong></p>";
echo __('Stock Qty', 'wpsc') . " <input type='text' name='quantity' value='0' size='10' />";
echo "<div style='font-size:9px; padding:5px;'><input type='checkbox' class='inform_when_oos' name='inform_when_oos' /> " . __('If this product runs out of stock set status to Unpublished & email site owner', 'wpsc') . "</div>";
echo "</div>";

I know it is this line, but nothing I have tried will work.

Any help?

Cheers

michael_gourlay 11th February 2011 08:16 PM

Re: Setting a checkbox as "on" by default
 
Have you tried setting the checked attribute on the input tag?

If so, maybe there is some javascript or something on the page setting it to not checked?

nxtgencreative 12th February 2011 02:08 AM

Re: Setting a checkbox as "on" by default
 
ya like michael wrote all you need to do is set the checked attribute. This is the code: checked="true".

Silke 12th February 2011 04:54 AM

Re: Setting a checkbox as "on" by default
 
add checked to the tag (see example)
[QUOTE]<input type='checkbox' CHECKED class='inform_when_oos' name='inform_when_oos' />[/QUOTE]

davidmeeonline 12th February 2011 07:20 PM

Re: Setting a checkbox as "on" by default
 
Thanks guys, will give it a try tonight!


All times are GMT -6. The time now is 10:16 AM.