I am trying to generate a username by using the slice method. I am trying to use the users First name and last name to generate a username. Can't seem to make it work.
Where am I going wrong?
<html>
<body>
<script>
function myFunction() {
var Firstname = document.getElementById("Firstname");
var LastName = document.getElementById("LastName");
var nameId = (Firstname.slice(1,3)+LastName.slice(0,3));
}
</script>
<p><input type="text" name="Firstname" id="Firstname" ></p><br/>
<p><input type="text" name="LastName" id="LastName" ></p>
<p id="nameId"></p>
<button onclick="myFunction()">Send</button>
</body>
</html>
If you're selecting the text from an input field, you'll need to add .value
So:
var Firstname = document.getElementById("Firstname").value;
var LastName = document.getElementById("LastName").value;
You're accessing the element with getElementById.
Try using document.getElementById("Firstname").value to get the value in your element.
Progress Bar width is not getting updated by the variable bound by angular scope in IE. I want to have a progress bar length to be updated by a variable in angular scope, for that i have tried using ...
Progress Bar width is not getting updated by the variable bound by angular scope in IE. I want to have a progress bar length to be updated by a variable in angular scope, for that i have tried using ...
I am trying to use blessed, a text UI lib for Node. I'd like to create windows dynamically (free them after use), but I could not find info in the docs about how to destroy them. I've tried to remove ...
I am trying to use blessed, a text UI lib for Node. I'd like to create windows dynamically (free them after use), but I could not find info in the docs about how to destroy them. I've tried to remove ...
If Google S2 favicon service can't find a favicon of a website, it returns a default image. I want to know that the favicon was not found so I can show some other default image (on my server), or ...
If Google S2 favicon service can't find a favicon of a website, it returns a default image. I want to know that the favicon was not found so I can show some other default image (on my server), or ...
I'm creating a site using Harp, and I was wondering if there is a way to use Jade blocks alongside the normal != yield way of working. Basically, for page specific scripts, I'd like to pass a block ...
I'm creating a site using Harp, and I was wondering if there is a way to use Jade blocks alongside the normal != yield way of working. Basically, for page specific scripts, I'd like to pass a block ...