ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to send a value for an UNCHECKED checkbox?

August 06, 2009 9:00pm

Subscribe [3]
  • #16 / Aug 07, 2009 12:00pm

    Mark Bowen

    12637 posts

    could try throwing your print_r($_POST) into cp.publish.php in the submit_new_entry function to see exactly what is making it to the publish code… I know that some posted variables get unset along the way, though your custom fields shouldn’t get touched I don’t think.

    Good idea might just try that. Actually I’ve just noticed that I didn’t mention that this is actually the status of the entry that I’m trying to set. Not really sure why it doesn’t pick up the value when checked though.

  • #17 / Aug 07, 2009 12:00pm

    ender

    1644 posts

    also you could try posting the form via ajax (malsup’s jquery form plugin is the easiest) and then looking at the NET -> XHR request tab in firebug or similar tool to see exactly what is being posted from the client.

  • #18 / Aug 07, 2009 12:07pm

    Mark Bowen

    12637 posts

    also you could try posting the form via ajax (malsup’s jquery form plugin is the easiest) and then looking at the NET -> XHR request tab in firebug or similar tool to see exactly what is being posted from the client.

    Well that unfortunately went a bit over my head there 😉

    Will look into that plugin though, thanks.

    Best wishes,

    Mark

  • #19 / Aug 07, 2009 12:15pm

    ender

    1644 posts

    I’m assuming you know what firebug is :p

    if you go to the “net” tab, and then hit the “XHR” button you’ll see ajax requests as they happen.

    open it up on http://www.keytosavannah.com/maps/search/ and mess with some of the controls on the form there, you’ll see some posts happen… if you click on one of the post requests it’ll expand and show 4 tabs: Headers, Post, Response, HTML.  If you click Post it’ll show the name->value pairs sent by the form to the server.  Since you’re manipulating this form with javascript you should check to make sure it’s sending what you think it’s sending… if it is then you have a server/php problem, if not you have a javascript/form problem.

  • #20 / Aug 07, 2009 12:49pm

    Environ-IT

    26 posts

    Well back in the day I always used to do this:

    <form>
    <input type="hidden" value="No" name="field_id_12" id="field_id_12" /> 
    <input type="checkbox" value="Yes" name="field_id_12" id="field_id_12" /> 
    
    <input type="submit" value="submit">
    </form>

    If the checkbox is checked it sends ‘Yes’ if it’s not checked it sends ‘No’.

    it worked 10 years ago

    Hope it helps

    Andrew

  • #21 / Aug 07, 2009 1:44pm

    Mark Bowen

    12637 posts

    Hiya,

    Well back in the day I always used to do this:

    <form>
    <input type="hidden" value="No" name="field_id_12" id="field_id_12" /> 
    <input type="checkbox" value="Yes" name="field_id_12" id="field_id_12" /> 
    
    <input type="submit" value="submit">
    </form>

    If the checkbox is checked it sends ‘Yes’ if it’s not checked it sends ‘No’.

    it worked 10 years ago

    Hope it helps

    Andrew

    Unfortunately the first thing I tried but it just doesn’t work in an SAEF. Works fine in any form that I create myself but not in an SAEF. I used to do that years ago too 😉

    I think I might post this into Tech Support although it may just get moved back to How To again although it does seem a little weird that a normal form will work just fine with that method but not an SAEF.

    Ingmar, any thoughts at all?

  • #22 / Aug 07, 2009 1:55pm

    Mark Bowen

    12637 posts

    Just in case anyone wants to see what I’m trying to do I’ve set up a very quick page here with a standard form on that I’ve made myself. This as you can see works fine with the hidden field trick.

    As soon as I place this into a Stand Alone Edit Form though it just doesn’t send anything from the checkbox and instead will only ever use the value of the hidden field :-(

    Form Test Page Demonstration

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases