0

hi, so i didnt know how to phrase this question in google to get some clue so im just gonna ask here. And im also not sure if this is the correct place to ask because im not sure what language id have to use.
anyway, i have a popup form which i did using js from a tutorial i found on the web. On the form users need to fill in event name, venue, date time and a theme input box which is connected to a checkbox, meaning that if the checkbox is checked users can type in the input box if it is not checked then the input box is readonly. So the thing im wondering is say if the user did not check the checkbox how do i default it that when the user clicks save the theme data is "NO"?

i hope i explained it well. if not heres the screenshot of my form and also some codes.

<script type="text/javascript">
           $(document).ready(function ()
           {
              $("#popupevent").click(function (e)
              {
                 ShowDialog(false);
                 e.preventDefault();
              });

              $("#cancel").click(function (e)
              {
                 HideDialog();
                 e.preventDefault();
              });

           });

           function ShowDialog(modal)
           {
              $("#overlay").show();
              $("#dialog").fadeIn(300);



                  if (modal)
                  {
                     $("#overlay").unbind("click");
                  }
                  else
                  {
                     $("#overlay").click(function (e)
                     {
                        HideDialog();
                     });
                  }
               }

               function HideDialog()
               {
                  $("#overlay").hide();
                  $("#dialog").fadeOut(300);
               } 

            </script>

<div id="dialog" class="web_dialog">
    <form name="create">
        <fieldset style="width:350px;">
            <legend>Create Event</legend>
            Event Name  :  <input type="text" name="event_name" required/></br>
            Type of event : <select style="verticle-align:top" name="event_type"><option value="" disabled selected>Choose type</option><option value="anniversary">Anniversary</option>
            <option value="wedding">Wedding</option><option value="conference">Conference</option>
            </select></br>
            Date : <input type="date" name="event_date" required/></br>
            Time : <input type="time" name="event_time" required/></br>
            Venue : <input type="text" name="event_venue" required/></br>
            Dresscode : <input type="text" name="event_code" required/></br>
            Theme : <input type="text" name="theme" disabled/> <input type="checkbox" name="check" onclick="enable()" />YES</br>
            <p style="float:right;"><input type="submit" name="save" id="save" value="Create Event" /><input type="submit" id="cancel" name="cancel" value="Cancel" /></p>
        </fieldset>
    </form>
</div>

40953d4a0dd6055faf2d0b4dd056a6c2cb67d9ac2e1a9b57980337599d998501

3
Contributors
4
Replies
13
Views
3 Years
Discussion Span
Last Post by JorgeM
0

also to add to that when i click save(i inputed all) it does not save into the database. why?

<?php
require "connection.php";

if(isset($_POST['save']))
{
    $e_name=mysql_real_escape_string($_POST['event_name']);
    $e_type=mysql_real_escape_string($_POST['event_type']);
    $e_date=mysql_real_escape_string($_POST['event_date']);
    $e_time=mysql_real_escape_string($_POST['event_time']);
    $e_venue=mysql_real_escape_string($_POST['event_venue']);
    $e_code=mysql_real_escape_string($_POST['event_code']);
    $e_theme=mysql_real_escape_string($_POST['theme']);

    $create = mysql_query("INSERT INTO ems VALUES('$e_type','$e_name','$e_date','$e_time','$e_venue','$e_code','$e_theme')");


}

?>
0

oh right. dang. its been awhile. forgot that. thanks. any ideas on my main prob?

0

So the thing im wondering is say if the user did not check the checkbox how do i default it that when the user clicks save the theme data is "NO"?

Include a conditional statement in your code and see if the "check" was included in the post.
You can check the value and if its not "Yes" then store the value of "No" in your variable.

In your PHP code you are going through all of the posted values except for this one checkbox?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.