0

Hey all I am new to JS Coding and am trying to learn. I am trying to make a button where once you click it it ask for an callsign, if the callsign matches a pre determined value, it takes you to a different page. My issue is the prompt doesn't show up.

HTML

<html>
<head>
    <title>AFLRP MDT</title>
    <link rel="apple-touch-icon" sizes="180x180" href="/assets/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicons/favicon-16x16.png">
<link rel="manifest" href="/assets/favicons/site.webmanifest">
<link rel="shortcut icon" href="/assets/favicons/favicon.ico">
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="msapplication-config" content="/assets/favicons/browserconfig.xml">
<meta name="theme-color" content="#0063bf">
    <link rel="stylesheet" type="text/css" href="cssKits/generalKit.css">

    <link rel="stylesheet" type="text/css" href="cssKits/fontKit.css">
    <link rel="stylesheet" type="text/css" href="cssKits/contentKit.css">
    <link rel="stylesheet" type="text/css" href="cssKits/gridKit.css">
     <meta charset="UTF-8">
     <meta name="keywords" content="Flashing Lights,RP,Role Play,FL, Australia, Australian, Police, Fire, EMS, Paramedic">
     <meta name="author" content="AFLRP Web Division">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="The official AFLRP MDT">
</head>
<body>

    <div id="mainBodyContent">
        <h1>MDT</h1>
        <p>MDT for AFLRP</p>
    </div>
    <div id="resourceArticlesList" align="center">
            <div id="resourceSelect">
                <div class="resourceRow">
                    <div class="resourceColumn">
                        <div id="resourceContent">
                        <h1>CAD</h1><br>
                        <p>Like mod packs and procedures</p>
                        <br><br>
                        <button id="generalButton" onclick="checkCADAuth()">CAD</button>
                    </div>
                    </div>
                    <div class="resourceColumn">
                        <div id="resourceContent">
                        <h1>MDT</h1><br>
                        <p>For regular </p><br><br>
                        <button id="generalButton" onclick="checkCADAuth()">Guides</button>
                    </div>
                    </div>
                </div>
            </div>
        </div>
    <script type="text/javascript" src="script.js"></script>
</body>
</html> 

JS

function checkCADAuth(){
var callsign = prompt("Please enter your callsign");
if (callsign = "5121" || "9264" || "454" || "616" ||) {
    window.location.href="cad.html";
}
else{
    window.alert("You are not MDT Authorised")
}
}
Samo2120
  • 179
  • 1
  • 2
  • 11
  • 2
    Comparision with ```==``` or ```===``` not with ```=```, in your JS. Also, you have an extra ```||``` in your ```if``` statement. –  Apr 25 '20 at 03:44
  • Thanks, that helped fix it – Samo2120 Apr 25 '20 at 03:49
  • Possible duplicate of [Check variable equality against a list of values](https://stackoverflow.com/questions/4728144/check-variable-equality-against-a-list-of-values) – esqew Apr 25 '20 at 04:16
  • you also need an to repeat the variable between each of your `||`s. Like: `if (callsign === "5121" || callsign === "9264" || callsign === "454" || callsign === "616" )` if you don't do this the condition will ALWAYS pass – WillD Apr 25 '20 at 04:24
  • Thanks WillD that fixed many problems, legend! – Samo2120 Apr 25 '20 at 04:29

0 Answers0