mardi 29 novembre 2016

Need help connecting JavaScript code to button that is also connecting to html file on computer [on hold]

I'm using Expression Web 4, all my files are in a folder on the Desktop, but the page says the file can't be found. I am trying to host from my computer since I will only have this up for 1 day.

It would show up in the search bar like this:
file:///C:/UsersnameDesktopName_websiteWebsitePage.html

But I have the file path like this:
C:\Users\name\Desktop\Name_website\WebsitePage.html

The html code:(these are only a few of many)
All of the check boxes are in a tag,
Each checkbox resides in it's own tag,

<form action="">
<div class="course" id="crse">
<input type="checkbox" name="course" value="53" id="crse53" class="auto-style2" /><span class="auto-style2">BMT-1650 Customer Service - 3 credits</span><br class="auto-style2"/>
<input type="checkbox" name="course" value="54" id="crse54" class="auto-style2" /><span class="auto-style2">Cyber Law - 3 credits</span><br class="auto-style2"/>
<input type="checkbox" name="course" value="55" id="crse55" class="auto-style2" /><span class="auto-style2">BMT-2880 Emergency Management - 3 credits</span><br class="auto-style2"/>
</div>
</form>

<input id="clickme"type="button" value="Find my Certificate" onclick="doFunction();"/>

The javascript code: I'm trying to connect the if statement to the button which will lead the user to certain html page that is stored on my computer. The file is the same folder as the other html files.

var crse53 = document.getElementById('crse53').checked,   
crse54 = document.getElementById('crse54').checked,   
crse55 = document.getElementById('crse55').checked,    
crse56 = document.getElementById('crse56').checked,   
crse57 = document.getElementById('crse57').checked,   
crse58 = document.getElementById('crse58').checked;


if (crse53 == false && crse54 == false && crse57 == false && crse58 == false){

var myBtn = document.getElementById('clickme');

myBtn.addEventListener('click', function(event) {
    window.location.href='C:\Users\name\Desktop\Name_website\WebsitePage.html';});

document.getElementById("clickme").onclick = doFunction;

} else {
alert("try again");
};

I don't know whats wrong. Is it the file path or the something else? If there is a more efficient way of doing this please let me know!!

Aucun commentaire:

Enregistrer un commentaire