How to do alert message box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chaos
    New Member
    • Jun 2007
    • 52

    How to do alert message box

    how to do alert message box when the user press on the button. The messages will be different if he select different status mode in the drop down menu.
    This is code of the selection

    select name="status" id="status">
    <option value="Pending" <?php if (!(strcmp("Pend ing", $row_ad_time['status']))) {echo "SELECTED"; } ?>>Pending</option>
    <option value="Approved " <?php if (!(strcmp("Appr oved", $row_ad_time['status']))) {echo "SELECTED"; } ?>>Approved</option>
    <option value="Rejected " <?php if (!(strcmp("Reje cted", $row_ad_time['status']))) {echo "SELECTED"; } ?>>Rejected</option>
    </select>
  • shoonya
    New Member
    • May 2007
    • 160

    #2
    Code:
    <select name="status" id="status" onchange=javascript:foo()>
    ..
    </select>
    
    function foo()
    {
    alert(document.getElementById('status').options[document.getElementById('staus').selectedIndex].text))
    
    
    alert(document.getElementById('status').options[document.getElementById('staus').selectedIndex].value))
    
    }
    you can use these two alerts to see the text/value set for each options
    Code:
    document.getElementById('status').value
    will work for mozilla only not for IE so dont use this whenever dealing with

    Code:
    <select>
    ...
    </select>
    shoonya

    Comment

    • chaos
      New Member
      • Jun 2007
      • 52

      #3
      Originally posted by shoonya
      Code:
      <select name="status" id="status" onchange=javascript:foo()>
      ..
      </select>
      
      function foo()
      {
      alert(document.getElementById('status').options[document.getElementById('staus').selectedIndex].text))
      
      
      alert(document.getElementById('status').options[document.getElementById('staus').selectedIndex].value))
      
      }
      you can use these two alerts to see the text/value set for each options
      Code:
      document.getElementById('status').value
      will work for mozilla only not for IE so dont use this whenever dealing with

      Code:
      <select>
      ...
      </select>
      shoonya
      thx shoonya for your help
      If i use IE for this project , wt other coding i can use??

      Comment

      • shoonya
        New Member
        • May 2007
        • 160

        #4
        same which i have given above

        enjoy and have fun

        shoonya

        Comment

        • chaos
          New Member
          • Jun 2007
          • 52

          #5
          Originally posted by shoonya
          same which i have given above

          enjoy and have fun

          shoonya
          Again , thx for your help

          Comment

          • chaos
            New Member
            • Jun 2007
            • 52

            #6
            Originally posted by shoonya

            shoonya
            Hi shoonya
            The code u give , it cant work in my project.
            Gt any other code can put in the coding below as this coding is use to update e time slot if it is approved.

            if (isset($_POST['status']))
            $states = $_POST['status']; else $states = "";
            // echo status;
            if($states == "Approved")
            {
            for($i=0;$i<cou nt($StudentGrou ps);$i++)
            {
            for($j=0;$j<$or iginalDuration; $j++)
            {
            $updateStatemen t1 = "UPDATE students SET _".($_POST['old_slot']+$j)."=0". " WHERE group_1='".$Stu dentGroups[$i]."'";

            $updateStatemen t3 = "UPDATE facilities SET _".($_POST['old_slot']+$j)."=0". " WHERE venue='".$_POST['o_venue']."'";

            $updateStatemen t5 = "UPDATE staff SET _".($_POST['old_slot']+$j)."=0". " WHERE staff_1='".$_PO ST['user_id']."'";

            $Result2 = mysql_query($up dateStatement1, $conn) or die(mysql_error ());
            $Result4 = mysql_query($up dateStatement3, $conn) or die(mysql_error ());
            $Result6 = mysql_query($up dateStatement5, $conn) or die(mysql_error ());
            }

            for($k=0;$k<$pr oposedDuration; $k++)
            {
            $updateStatemen t2 = "UPDATE students SET _".($_POST['new_slot']+$k)."=".$_POST['moduleID']." WHERE group_1='".$Stu dentGroups[$i]."'";

            $updateStatemen t4 = "UPDATE facilities SET _".($_POST['new_slot']+$k)."=".$_POST['moduleID']." WHERE venue='".$_POST['p_venue']."'";

            $updateStatemen t6 = "UPDATE staff SET _".($_POST['new_slot']+$k)."=".$_POST['moduleID']." WHERE staff_1='".$_PO ST['user_id']."'";

            $Result3 = mysql_query($up dateStatement2, $conn) or die(mysql_error ());
            $Result5 = mysql_query($up dateStatement4, $conn) or die(mysql_error ());
            $Result7 = mysql_query($up dateStatement6, $conn) or die(mysql_error ());
            }
            $Result1 = mysql_query($up dateSQL, $conn) or die(mysql_error ());
            }
            }

            $updateGoTo = "timetable_reco rd_submitted.ph p";
            if (isset($_SERVER['QUERY_STRING']))
            {
            $updateGoTo .= (strpos($update GoTo, '?')) ? "&" : "?";
            $updateGoTo .= $_SERVER['QUERY_STRING'];
            }

            Comment

            • chaos
              New Member
              • Jun 2007
              • 52

              #7
              Originally posted by shoonya

              shoonya
              how to do alert message box when the user press on the button.
              <input type="submit" name="Submit" value="Submit" onClick="checks tatus()">

              Go to checkstatus function to find up wt option is selected ( PENDING, APPROVED, REJECTED )

              This is code of the selection

              select name="status" id="status">
              <option value="Pending" <?php if (!(strcmp("Pend ing", $row_ad_time['status']))) {echo "SELECTED"; } ?>>Pending</option>
              <option value="Approved " <?php if (!(strcmp("Appr oved", $row_ad_time['status']))) {echo "SELECTED"; } ?>>Approved</option>
              <option value="Rejected " <?php if (!(strcmp("Reje cted", $row_ad_time['status']))) {echo "SELECTED"; } ?>>Rejected</option>
              </select>

              The code below using to update the time slot
              if (isset($_POST['status']))
              $states = $_POST['status']; else $states = "";
              // echo status;
              if($states == "Approved")
              {
              for($i=0;$i<cou nt($StudentGrou ps);$i++)
              {
              for($j=0;$j<$or iginalDuration; $j++)
              {
              $updateStatemen t1 = "UPDATE students SET _".($_POST['old_slot']+$j)."=0". " WHERE group_1='".$Stu dentGroups[$i]."'";

              $updateStatemen t3 = "UPDATE facilities SET _".($_POST['old_slot']+$j)."=0". " WHERE venue='".$_POST['o_venue']."'";

              $updateStatemen t5 = "UPDATE staff SET _".($_POST['old_slot']+$j)."=0". " WHERE staff_1='".$_PO ST['user_id']."'";

              $Result2 = mysql_query($up dateStatement1, $conn) or die(mysql_error ());
              $Result4 = mysql_query($up dateStatement3, $conn) or die(mysql_error ());
              $Result6 = mysql_query($up dateStatement5, $conn) or die(mysql_error ());
              }

              for($k=0;$k<$pr oposedDuration; $k++)
              {
              $updateStatemen t2 = "UPDATE students SET _".($_POST['new_slot']+$k)."=".$_POST['moduleID']." WHERE group_1='".$Stu dentGroups[$i]."'";

              $updateStatemen t4 = "UPDATE facilities SET _".($_POST['new_slot']+$k)."=".$_POST['moduleID']." WHERE venue='".$_POST['p_venue']."'";

              $updateStatemen t6 = "UPDATE staff SET _".($_POST['new_slot']+$k)."=".$_POST['moduleID']." WHERE staff_1='".$_PO ST['user_id']."'";

              $Result3 = mysql_query($up dateStatement2, $conn) or die(mysql_error ());
              $Result5 = mysql_query($up dateStatement4, $conn) or die(mysql_error ());
              $Result7 = mysql_query($up dateStatement6, $conn) or die(mysql_error ());
              }
              $Result1 = mysql_query($up dateSQL, $conn) or die(mysql_error ());
              }
              }

              $updateGoTo = "timetable_reco rd_submitted.ph p";
              if (isset($_SERVER['QUERY_STRING']))
              {
              $updateGoTo .= (strpos($update GoTo, '?')) ? "&" : "?";
              $updateGoTo .= $_SERVER['QUERY_STRING'];
              }



              if($states == "Rejected")
              {
              $Result1 = mysql_query($up dateSQL, $conn) or die(mysql_error ());
              }
              $updateGoTo = "timetable_reco rd_submitted.ph p";

              if (isset($_SERVER['QUERY_STRING']))
              {
              $updateGoTo .= (strpos($update GoTo, '?')) ? "&" : "?";
              $updateGoTo .= $_SERVER['QUERY_STRING'];
              }
              }

              Comment

              • chaos
                New Member
                • Jun 2007
                • 52

                #8
                Someone Help Me Pls !!

                Comment

                • bonski
                  New Member
                  • Jun 2007
                  • 53

                  #9
                  Originally posted by chaos
                  Someone Help Me Pls !!
                  hello chaos..

                  try this.. ^_____^

                  [HTML]<html>
                  <head>
                  <script language="javas cript" type="text/javascript">

                  function showStatus(stat us){
                  alert(status);
                  }

                  </script>
                  </head>
                  <body>
                  <form name="form_name " action="#" method="post">
                  <select name="status" id="status" onchange="showS tatus(this.valu e)">
                  <option value="Pending" >Pending</option>
                  <option value="Approved ">Approved</option>
                  <option value="Rejected ">Rejected</option>
                  </select>
                  </form>
                  </body>
                  </html>[/HTML]


                  bonski

                  Comment

                  • chaos
                    New Member
                    • Jun 2007
                    • 52

                    #10
                    Originally posted by bonski
                    hello chaos..

                    try this.. ^_____^

                    [HTML]<html>
                    <head>
                    <script language="javas cript" type="text/javascript">

                    function showStatus(stat us){
                    alert(status);
                    }

                    </script>
                    </head>
                    <body>
                    <form name="form_name " action="#" method="post">
                    <select name="status" id="status" onchange="showS tatus(this.valu e)">
                    <option value="Pending" >Pending</option>
                    <option value="Approved ">Approved</option>
                    <option value="Rejected ">Rejected</option>
                    </select>
                    </form>
                    </body>
                    </html>[/HTML]


                    bonski
                    HI bonski !!

                    I want to press e submit button then it will pop out e alert message

                    Comment

                    • bonski
                      New Member
                      • Jun 2007
                      • 53

                      #11
                      Originally posted by chaos
                      HI bonski !!

                      I want to press e submit button then it will pop out e alert message

                      sorry chaos... i didn't see the line "press the submit button"... hahaha.. my bad.. my bad...


                      ok.. here it is..

                      [HTML]<html>
                      <head>
                      <script language="javas cript" type="text/javascript">
                      function checkForm(){
                      var status = document.getEle mentById("statu s").value;
                      alert(status);
                      }
                      </script>
                      </head>

                      <body>
                      <form name="form_name " action="#" method="post">
                      <select name="status" id="status">
                      <option value="Pending" >Pending</option>
                      <option value="Approved ">Approved</option>
                      <option value="Rejected ">Rejected</option>
                      </select>
                      </form>
                      <input type="button" name="submit" value="Submit" onclick="checkF orm()"/>
                      </body>
                      </html>[/HTML]

                      ^___^.. bonski

                      Comment

                      Working...