It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

two scripts are not playing nice with each other.

two scripts are not playing nice with each other.

Postby jeff5656 on Sun Apr 06, 2008 5:26 pm

I have a calendar pop js and and form validator . For some reason, adding the calendar one makes the formvalidator not work. Can anyone help me?
Here is what I have in the header:
Code: Select all
<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);
}

//-->


pertinent Form part:
Code: Select all
<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" />&nbsp;<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>


submit button code:

Code: Select all
<input type="submit" name="Submit" value="Add Patient" onClick="return check('newreminders', this.name)">
jeff5656
 
Posts: 3
Joined: Sun Apr 06, 2008 5:21 pm

Postby webmaster on Sun Apr 06, 2008 7:03 pm

Hi and welcome to DEVPPL!

There are probably some variables with the same name in both scripts. Check that first.
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby rangana on Mon Apr 07, 2008 1:44 am

Probably, your formvalidator.js conflicts with your inline check function ;)

...Get firebug...and see what the error is :)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby jeff5656 on Mon Apr 07, 2008 9:24 am

um, can you be more specific. I do not know js, am a beginner. What is an inline check function and how would I make it NOT conflict?

And for replier #1, *which* variables?

This same exact form works on another php file - I just copied and pasted and they both look the same to me.

I tried firebug but I do not know how to use it. It does not help me figure out why the exact same js code works in one php file and not in the other. I found out it has nothing to do with the calendar js script. When I remove that, formvalidator still doesn't work.
Last edited by jeff5656 on Mon Apr 07, 2008 9:42 am, edited 1 time in total.
jeff5656
 
Posts: 3
Joined: Sun Apr 06, 2008 5:21 pm

Postby rangana on Mon Apr 07, 2008 9:32 am

JS is a shortcut for Javascript (for me).

You have a check function in your inline JS, which I thought would have established conflict with your formvalidator js.

I was asking for the source code of formvalidator.js.

With your code above, the error is this:
Code: Select all
onClick="cal.select(document.forms['cin'].date_enroll,'anchor1','MM/dd/yyyy'); return false;

...and your JS is only:
Code: Select all
<SCRIPT LANGUAGE="JavaScript">
var cal = new CalendarPopup();
</SCRIPT>
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 4 guests