I am learning Javascript.
I want to:
- Read a user input (a number that is inserted in to a link address)
- Insert the input into a hyperlink string.
- Launch the hyperlink.
I am able to read the input and create the string but I cannot get it to launch the website. The string looks correct, however, I am not sure if the problem is actually the string or that I am not launching it correctly. I am able to find examples of each step, but cannot seem to put them together.
Here is my current code: (can't test the link because I cannot see it).
I am sorry if this doesn't come out correctly. It look correct when I paste it.
<script type="text/javascript" > function myLink() { var numberEntered = document.getElementById("lessNum").value; //Read input var lessonlink = 'http://www.ASmarterWayToLearn.com/js/' + numberEntered + '.html'; //Create link window.open(lessonLink); //Go to link document.getElementById("theLink").value = lessonLink; // check link address } </script> <!-- Read Lesson number --> <form> Lesson Number:<br> <input type="text" id="lessNum" onBlur="myLink();"><p> <!-- Display link for verification --> Link:<br> <input type="text" id="theLink" style="width: 400px;"><p> </form> <p>