Hello there
am working on a website where members can add event. Once the member select the event type, the form for that event will appear. below are the pages i did. I also included jquery-1.7.2.min.js. Once i select any event on the add_event.php it brings the right form as i have prepared them in events_forms.php. I need to confirm if some fields are empty. but once the submit button is clicked, the form will just disappear without confirming if the required fields are empty or not or process the form. WHAT DO I DO, pls help.

add_event.php

<head>
<script type="text/javascript" language="javascript" src="../scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" language="javascript">
function cambiar(dato)
{
  $.ajax({
    url: "events_forms.php",
    async:true,
    contentType: "application/x-www-form-urlencoded",
    data: "value="+dato,
    dataType: "html",
    global: true,
    cache: false,
    ifModified: false,
    processData:true,
    success: function(datos)
    {
      document.getElementById('lugarDeCambio').innerHTML=datos;
    },
    timeout: 3000,
    type: "GET"
  });
}
</script>
</head>

if(isset($_POST[Submit])){
        if($evento=='AGM'){
                        if($_POST[org]=="") echo "Enter your Org.";
                        else{
                                 echo "Thank you.";
                                 }
        }
        elseif($evento=='Birthday'){
                        if($_POST[celebrant]=="") echo "Enter the celebrant.";
                        else{
                        //my other scripts go here
                         echo "Thank you.";
                        }
        }
        else{
                        if($_POST[bride]=="" or $_POST[groom]=="") echo "Enter the Bride & the Groom.";
                        else{
                        //my other scripts go here
                         echo "Thank you.";
                        }
        }
}
?>

<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                    <table width="400" border="0" align="center" cellpadding="5" cellspacing="0">
              <tr>
                <td width="110" align="left" valign="top">Event Type </td>
                <td width="270" align="left" valign="top">
                                <select name="evento" onclick="cambiar(this.value)">
                    <option>Select</option>
                    <option value="AGM">AGM</option>
                    <option value="Birthday">Birthday</option>
                    <option value="Wedding">Wedding</option>
                </select></td>
              </tr>
              <tr>
                <td colspan="2" align="left" valign="top"><p>&nbsp;</p>
                  <div id="lugarDeCambio" align="center">
                    <?php
echo $eventoElegido;
?></div>
                  </td>
              </tr>
            </table>
                    <p align="center"><label></label>
                    </p>
                  </form>

events_forms.php

<?php
if($_GET['value']=='AGM')
{
?>
<p>&nbsp;</p>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td colspan="2" align="center" valign="top">AGM FORM </td>
  </tr>
  <tr>
    <td width="30%" align="left" valign="top">Organization: *</td>
    <td width="70%" align="left" valign="top"><label>
      <input name="org" type="text" id="org" size="30">
    </label></td>
  </tr>
  <tr>
    <td align="left" valign="top">AGM Brief: </td>
    <td align="left" valign="top"><input name="brief" type="text" id="brief" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Date:</td>
    <td align="left" valign="top"><input name="date" type="text" id="date" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Expected People: </td>
    <td align="left" valign="top"><input name="people" type="text" id="people" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Venue:</td>
    <td align="left" valign="top"><input name="venue" type="text" id="venue" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Time:</td>
    <td align="left" valign="top"><input name="time" type="text" id="time" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left" valign="top"><input type="submit" name="Submit" value="Submit" /></td>
  </tr>
</table>
<p>
<?php
}
elseif($_GET['value']=='Birthday')
{
?>
</p>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td colspan="2" align="center" valign="top">BIRTHDAY FORM </td>
  </tr>
  <tr>
    <td width="30%" align="left" valign="top">Celebrant: *</td>
    <td width="70%" align="left" valign="top"><label>
      <input name="celebrant" type="text" id="celebrant" size="30">
    </label></td>
  </tr>
  <tr>
    <td align="left" valign="top">Date of Birthday </td>
    <td align="left" valign="top"><input name="dob" type="text" id="dob" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Date:</td>
    <td align="left" valign="top"><input name="date" type="text" id="date" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Expected People: </td>
    <td align="left" valign="top"><input name="people" type="text" id="people" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Venue:</td>
    <td align="left" valign="top"><input name="venue" type="text" id="venue" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Time:</td>
    <td align="left" valign="top"><input name="time" type="text" id="time" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left" valign="top"><input name="Submit" type="submit" id="Submit" value="Submit" /></td>
  </tr>
</table>
<p>
<?php
}
elseif($_GET['value']=='Wedding')
{
?>
</p>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td colspan="2" align="center" valign="top">WEDDING  FORM </td>
  </tr>
  <tr>
    <td width="30%" align="left" valign="top">Bride's Name * </td>
    <td width="70%" align="left" valign="top"><label>
      <input name="institution" type="text" id="institution" size="30">
    </label></td>
  </tr>
  <tr>
    <td align="left" valign="top">Groom's Name * </td>
    <td align="left" valign="top"><input name="breif" type="text" id="breif" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Date:</td>
    <td align="left" valign="top"><input name="date" type="text" id="date" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Expected People: </td>
    <td align="left" valign="top"><input name="people" type="text" id="people" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Venue:</td>
    <td align="left" valign="top"><input name="venue" type="text" id="venue" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">Time:</td>
    <td align="left" valign="top"><input name="time" type="text" id="time" size="30"></td>
  </tr>
  <tr>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left" valign="top"><input name="Submit" type="submit" id="Submit" value="Submit" /></td>
  </tr>
</table>
<p>
<?php
}
else echo 'Select Event Type to display the Form.';
?>
</p>

dont know if you make a mistake,but you need <?php on line 26

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.