Go to Post If this thread isn't a sign that CD is going through some serious withdrawals, I don't know what is. - Ty Tremblay [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-02-2014, 09:15
cmockjr's Avatar
cmockjr cmockjr is offline
Registered User
FRC #1741
 
Join Date: Feb 2014
Location: Indiana
Posts: 1
cmockjr is an unknown quantity at this point
A little help on some Javascript

Ok, I have been trying to make a php file cancel submitting the data the user enters when two pieces of information are the same using javascript. As far as I know, what I have tried should be working fine but the form keeps on submitting. Here is what I have:
javascript:
<script type="text/javascript">
function validateForm()
{
var Team1=document.getElementById("Team1").value;
var Team2=document.getElementById("Team2").value;
var Team3=document.getElementById("Team3").value;
if (Team1 != Team2) && (Team1 != Team3) && (Team2 != Team3)
{
return true;
} else {
alert('Choose 3 different Teams for the Match!');
return false;
}
}
</script>
HTML/PHP that is used to submit the match by activating another PHP file that submits the match to a database:
<input type="submit" value="Add/Update" style="margin: 0 auto" formaction="MatchTable.php" onsubmit="return validateForm();">
If anyone could help me on this, it would be really awesome.
Reply With Quote
  #2   Spotlight this post!  
Unread 15-02-2014, 16:58
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: A little help on some Javascript

See this StackOverflow thread
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #3   Spotlight this post!  
Unread 15-02-2014, 18:45
artdutra04's Avatar
artdutra04 artdutra04 is offline
VEX Robotics Engineer
AKA: Arthur Dutra IV; NERD #18
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2002
Location: Greenville, TX
Posts: 3,078
artdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond repute
Re: A little help on some Javascript

You need to wrap another set of parenthesis around the if statement to prevent a syntax error.

Code:
if (Team1 != Team2) && (Team1 != Team3) && (Team2 != Team3)
should be

Code:
if ((Team1 != Team2) && (Team1 != Team3) && (Team2 != Team3))
__________________
Art Dutra IV
Robotics Engineer, VEX Robotics, Inc., a subsidiary of Innovation First International (IFI)
Robowranglers Team 148 | GUS Robotics Team 228 (Alumni) | Rho Beta Epsilon (Alumni) | @arthurdutra

世上无难事,只怕有心人.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:38.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi