Jump to content

how to call java script from php


fareedreg

Recommended Posts

Please see Below coding and tell me what is wrong I am trying to call external java script on submit button and checking date in dd/mm/yyyy format

 

 

 

 

 

 

 

<?php

 

$memval=101;

 

include('connect.php');

 

$Tb = "issue";

 

mysql_select_db($Db, $link);

                           

$query = "select issue_id from issue order by issue_id";

 

$result= mysql_query($query,$link);

 

while ($row=mysql_fetch_array($result))

{

    $f1=$row["issue_id"]; 

}                       

 

  if ($f1>=101)

  {

    $memval=$f1+1;   

  }

 

  mysql_close($link);

?>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<style type="text/css">

<!--

.style4 {font-size: 36px}

-->

</style>

<script type="text/javascript" src="datevalidate.js"></script> 

<script type="text/javascript" src="selectmembername.js"></script>       

<script type="text/javascript" src="selectbookname.js"></script>

</head>

<body>

<div align="center"><img src="images/libimage.jpg" width="998" height="103" /></div>

<p> </p>

<table width="572" height="61" align="center">

  <tr>

    <td align="center" valign="middle"><p class="style4">BOOK ISSUE</p>

    <p><a href="index.html"><img src="images/mainmenu.gif" width="128" height="40" /></a><span class="style4"><a href="issue.html"><img src="images/return.gif" width="128" height="40" /></a></span></p></td>

  </tr>

</table>

<p> </p>

<form name="issue" method="post" action="bookissueupdate.php" onSubmit="return ValidateForm()">

<table width="585" border="0" align="center">

  <tr>

    <td width="183">Issue Id</td>

    <td width="300"><input readonly="readonly" name="txtissueid" type="text" value="<?php echo $memval;?>" id="txtissueid"/></td>

  </tr>

  <tr>

    <td>Member Id</td>

    <td>

 

 

  <select onchange="showUser(this.value);">

   

    <?php

 

    include('connect.php');

 

    $Tb = "mem_master";

 

    mysql_select_db($Db, $link);

                           

    $query = "select mem_id from $Tb order by mem_id";

 

    $result= mysql_query($query,$link);

 

    $fel=mysql_num_fields($result);

    $nro=mysql_num_rows($result);

 

    if ($nro>0)

 

    {

   

        //echo "<select Member='itemmem'>\n";

       

        echo "<option>-- Select Member --</option>\n";   

       

    while ($row=mysql_fetch_array($result))

 

        {

   

            echo "<option value='$row[mem_id]'>$row[mem_id]</option>\n";

       

        }                       

                             

    }

 

    mysql_close($link);

 

  ?>

    </select>  </tr>

  <tr>

    <td>Member Name </td>

    <td>

    <div name="txtHint" id="txtHint"><b></b></div>    </td>

  </tr>

  <tr>

    <td>Book Id</td>

    <td>

   

    <select onchange="showBook(this.value);">

   

    <?php

 

    include('connect.php');

 

    $Tb = "book_master";

 

    mysql_select_db($Db, $link);

                           

    $query = "select book_id from $Tb order by book_id";

 

    $result= mysql_query($query,$link);

 

    $fel=mysql_num_fields($result);

    $nro=mysql_num_rows($result);

 

    if ($nro>0)

 

    {

   

        //echo "<select Member='itemmem'>\n";

       

        echo "<option>-- Select Book --</option>\n";   

       

    while ($row=mysql_fetch_array($result))

 

        {

   

            echo "<option value='$row[book_id]'>$row[book_id]</option>\n";

       

        }                       

                             

    }

 

   

    mysql_close($link);

 

  ?>

    </select>    </td>

  </tr>

  <tr>

   

  </tr>

  <tr>

    <td> </td>

    <td><div id="txtBook"><b></b></div></td>

  </tr>

  <tr>

 

    <td>Issue Date</td>

    <td><input name="txtissue" type="text" id="txtissue" size="10" maxlength="10"/>

    (dd/mm/yyyy)</td>

  </tr>

  <tr>

    <td>Issue Upto</td>

    <td><input name="txtissyyto" type="text" id="txtissyyto" size="10" maxlength="10" />

(dd/mm/yyyy)</td>

  </tr>

</table>

<p> </p>

<table width="129" border="0" align="center">

  <tr>

    <td width="66"><input name="cmdsubmit" type="submit" id="cmdsubmit" value="Submit" /></td>

    <td width="53"><input type="reset" name="cmdclear" id="cmdclear" value="Clear" /></td>

  </tr>

</table>

</form>

<p> </p>

<p> </p>

<p> </p>

 

 

<script language="JavaScript" type="text/javascript"> 

 

validateDate("txtissue");

 

</script>

 

</body>

 

</html>

 

 

 

 

 

 

 

 

js

 

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}

{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 function validateDate(fld) \{\par

    var RegExPattern = /^((((0?[1-9]|[12]\\d|3[01])[\\.\\-\\/](0?[13578]|1[02])[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d\{2\}))|((0?[1-9]|[12]\\d|30)[\\.\\-\\/](0?[13456789]|1[012])[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d\{2\}))|((0?[1-9]|1\\d|2[0-8])[\\.\\-\\/]0?2[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d\{2\}))|(29[\\.\\-\\/]0?2[\\.\\-\\/]((1[6-9]|[2-9]\\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\\d)?\\d\{2\}))|((0[1-9]|[12]\\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\\d)?\\d\{2\}))|((0[1-9]|1\\d|2[0-8])02((1[6-9]|[2-9]\\d)?\\d\{2\}))|(2902((1[6-9]|[2-9]\\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;\par

    var errorMessage = 'Please enter valid date as month, day, and four digit year.\\nYou may use a slash, hyphen or period to separate the values.\\nThe date must be a real date. 30/2/2000 would not be accepted.\\nFormay dd/mm/yyyy.';\par

    if ((fld.value.match(RegExPattern)) && (fld.value!='')) \{\par

        alert('Date is OK'); \par

    \} else \{\par

        alert(errorMessage);\par

        fld.focus();\par

    \} \par

\}\par

\par

}

 

Link to comment
https://forums.phpfreaks.com/topic/188163-how-to-call-java-script-from-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.