Jump to content

JavaScript embedded into HTML

printf_cyber
<!DOCTYPE html>
<html>
<head>
	<title>Password Generator</title>
</head>
<body>

Characters: <input type="number" id="charNum" value="16" min="8" max="100" /><br />
Number: <input type="checkbox" id="num"/><br />
Symbol: <input type="checkbox" id="sym"/><br /><br />
<button id="submit">Submit</button><br /><br />
Your Password: <input type="text" id="yourPw" size="100"/>

<style type="text/css">
table td{
  /* border: #000 solid 1px; */
  border-bottom: 1px solid #000;
  padding: 5px;
}
}
</style>

<script>
var char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var num = '0123456789';
var sym = '!@#$%^&*=-_';

var charNum = document.getElementById("charNum");
var numBox = document.getElementById("num");
var symBox = document.getElementById("sym");
var submit = document.getElementById("submit");
var yourPw = document.getElementById("yourPw");

submit.addEventListener("click",function(e){
    var characters = char;
    (numBox.checked) ? characters += num : '';
    (symBox.checked) ? characters += sym : '';
    yourPw.value = password(charNum.value, characters);
});

function password(l,characters){
		var pwd = '';
    for(var i = 0; i<l; i++){
    		pwd += characters.charAt(Math.floor(Math.random() * characters.length));
    }
    return pwd;
}
</script>

</body>
</html>

Hey guys,

 

So the HTML webpage opens i can insert no.s use all the buttons but I don't get the output of password in the field upon clicking the "Submit" button.

Hoping for a positive response,

Basil

Link to comment
Share on other sites

Link to post
Share on other sites

Browser related I expect. I ran your code in my Chrome browser and it worked.

If you're interested in a product please download and read the manual first.

Don't forget to tag or quote in your reply if you want me to know you've answered or have another question.

Link to comment
Share on other sites

Link to post
Share on other sites

you do have an invalid structure. You css style has double closing brackets. Chrome will automatically correct that

 

<style type="text/css">
table td{
  /* border: #000 solid 1px; */
  border-bottom: 1px solid #000;
  padding: 5px;
}
} /* <----- here is your issue */
</style>

 

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 months later...
On 9/20/2019 at 10:59 PM, Franck said:

you do have an invalid structure. You css style has double closing brackets. Chrome will automatically correct that

 


<style type="text/css">
table td{
  /* border: #000 solid 1px; */
  border-bottom: 1px solid #000;
  padding: 5px;
}
} /* <----- here is your issue */
</style>

 

lmao i just wanna thank u for the reply i figured it out later on and never bothered to check the forums lol
thnx

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×