Jump to content

Recommended Posts

  • Administrators
Posted

I have a form that is a list of checkboxes. I need the value to change to a 1 if the box is checked and 0 if it is not checked. Here is my current form. If there is a better way to this I'm open to changing it.

<h4 class="text-center">Here you can choose how you would like to be notified about showing activities.</h4>
                            <form role="form" method="post" action="submit.php" style="margin-left:50px;">
                                <h3>Email</h3>
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" value="<?php echo $notprefs['email_my_showings'];?>" name="email_my_showings" <?php if($notprefs['email_my_showings'] == 1) {echo 'checked';}?>>
                                        Email confirmations of showings I schedule.
                                    </label>
                                </div>
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" value="<?php echo $notprefs['email_other_showings'];?>" name="email_other_showings" <?php if($notprefs['email_other_showings'] == 1) {echo 'checked';}?>>
                                        Email me when someone schedules a showing on one of my listings
                                    </label>
                                </div>
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" value="<?php echo $notprefs['email_leave_feedback'];?>" name="email_leave_feedback" <?php if($notprefs['email_leave_feedback'] == 1) {echo 'checked';}?>>
                                        Email reminders to leave feedback.
                                    </label>
                                </div>
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" value="<?php echo $notprefs['email_received_feedback'];?>" name="email_received_feedback" <?php if($notprefs['email_received_feedback'] == 1) {echo 'checked';}?>>
                                        Email reminders for received feedback.
                                    </label>
                                </div>
                                <h3>Text Message</h3>
                                <h6>Coming Soon</h6>
                                <input type="hidden" name="submittype" value="7"/>
                                <input type="hidden" name="userid" value="<?php echo $userid;?>"/>
                                <button type="submit" class="btn btn-default">Submit</button>
                            </form>
  • Administrators
Posted

Fixed by adding this piece of jquery:

$('.checkbox input').on('change', function(){
  $(this).val($(this).prop('checked') ? '1' : '0');
  }
);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...