Jump to content

2 java scripts in one php file


jeff5656

Recommended Posts

I have a calendar pop js and and required field js.  For some reason, adding the calendar one makes the other one not work.  I am sure it has something to do with the code near the submit button?

 

The js scripts in the header:

<SCRIPT LANGUAGE="JavaScript" SRC="../CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var cal = new CalendarPopup();
</SCRIPT>

<script type="text/javascript" src="../formvalidator.js"></script>
<script type="text/javascript">
<!--
function check(formname, submitbutton) {
  var errors = '';
  errors += checkText(formname, 'your_name', 'Your Name');
  errors += checkText(formname, 'mrn', 'MRN');
  errors += checkText(formname, 'name', 'Your Name');
  errors += checkText(formname, 'card_no', 'Card No.');
  return checkThisForm(formname, submitbutton, errors);
}

//-->

 

The key parts of the  form:

<form id="cin" name="cin" method="post" action="cin_addpatient.php">
  <table>
<th>Your Name</th>
  <td><input type="text" name="your_name" /></td>
  </tr>
  <tr></tr>
  <th>Patient Last Name</th>
  <td><input type="text" name="name" /></td>
  </tr>
  <tr></tr>
  <th>Card No.</th>
  <td><input type="text" name="card_no" id="card_no" /></td></tr>
  <tr></tr>
  <th>Date of enrollment</th>
  <tr>
<td><input type="text" name="date_enroll" id="date_enroll" /> <A HREF="#"
   onClick="cal.select(document.forms['cin'].date_enroll,'anchor1','MM/dd/yyyy'); return false;"
   NAME="anchor1" ID="anchor1"><img src="../calendaricon.gif" width="16" height="16" border="0"></A></td></tr>

 

and the code near the submit button:

 <input type="submit" name="Submit" value="Add Patient" onClick="return check('newreminders', this.name)">

 

The calendar script works on the form, but not the required fields.  If I don't enter something, the form still gets processed.

Link to comment
https://forums.phpfreaks.com/topic/99829-2-java-scripts-in-one-php-file/
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.