Still cannot get the results desired. Appreciate a hint.
Not sure what you are really looking as a result ? I have already done the solution you where asking (5,12) will have an input of 5,6,7,8,9,10,11,12 not sure what else you want ?
…
Tempdocument.getElementById(‘btn’).addEventListener(‘Click’, example);
function example(){
my-form.first.value = “5”;
my-form.second.value = “12”;
};
document.getElementById(‘btn’).addEventListener(‘Click’, calculate);
//calculate(“5”, “12”);
function calculate(first, second){
// get inputs of both textfields and change data type, String to number
var txt_one = Number(document.getElementById(‘first’).value);
var txt_two = Number(document.getElementById(‘second’).value);
// display results in the DOM textarea
var textAreaResults = document.getElementById(“my-values”);
for (var k = txt_one; k <= txt_two; ++k){
textAreaResults.innerHTML += k + ‘\n’;
}
};
…
…
TempYou are not using 3 backticks. Look at the example in my first reply. It explains where to find the backtick character on your keyboard.
Please share the code as according to properly display code as post.
so if you wan to populate the boxes with 5 and 12 you need, as you wanted, i add another function where you called back and place the two input boxes values when the DOM its done loading.
You also doing an eventListener to a btn on the function example that do not exist.
no need to do that.
document.getElementById('btn').addEventListener('click', calculate);
function example(){
// You populate this when DOM Loads.
var text1 = document.getElementById('first').value = "5";
var text1 = document.getElementById('second').value = "12";
};
// Calling the function to set both boxes polulating.
example();
function calculate(first, second){
// get inputs of both textfields and change data type, String to number
var txt_one = Number(document.getElementById('first').value);
var txt_two = Number(document.getElementById('second').value);
// display results in the DOM textarea
var textAreaResults = document.getElementById("my-values");
for (var k = txt_one; k <= txt_two; ++k){
textAreaResults.innerHTML += k + '\n';
}
};
If you want the boxes to be populated with the 5 and 12 that is how you should be doing it.
CodePen
https://codepen.io/ivanmt07/pen/KKpJgZw
Sorry, what I want is when the button is clicked, for the two textboxes to be populated with 5 and 12 respectively and then the textarea to print 5 through 12, one digit at a time. Thank you.
Glad to help you around, just try to be a little more specific next time around so we can help you in a faster and better way and make sure code its posted as its stated. There are very good developers here so, i know they will also help you around.
Hope i was able to help with your solution. Please follow the code with the steps i have show.
codePen:
https://codepen.io/ivanmt07/pen/KKpJgZw?editors=1010
document.getElementById('btn').addEventListener('click', calculate);
function calculate(first, second){
// 1. Grab the input values
// 2. Convert them into numbers and assign the proper values "5" and "12" respectively.
var txtOneNumber = Number(document.getElementById('first').value = "5");
var txtTwoNumber = Number(document.getElementById('second').value = "12");
// display results in the DOM textarea
var textAreaResults = document.getElementById("my-values");
for (var k = txtOneNumber; k <= txtTwoNumber; ++k){
textAreaResults.innerHTML += k + '\n';
}
};
I set a spoiler so you be able to write done the code and work your way. I think that’s the best way of learning.
Thank you for your time.
Want to ask you for few more help.
https://codepen.io/ashliii/pen/NWqeJZe
Wanted to populate the two textboxes manually and/or using a button, called btn2 to have the same effect as before. Ie-to show all numbers in the textarea.
Also, wanted to use a button called btn3 to clear all data in the two text boxes and the textarea. Thank you.
Looks like your Codepen is already doing what you are asking.
Yes Randel. I tried but never really got the hang of three ticks approach you wanted me to get used to. I got the impression that the three ticks meant to type three periods, followed by pressing enter key and pasting the code, followed by enter key again and ending with three periods, rights. But this did not work for me. What was I doing wrong?. Thanks.
A backtick character on most US keyboards is located to the left of the number 1 on the keyboard.
Got the backtick keyborad figured out. Thanks.
@imendieta @RandellDawson how do I get involve in a project, please? I’m very new to this FreeCodeCamp and I really want to get my hands dirty by joining a project that I can be part of and work on whatever they are working on. Please, kindly advise thanks in advance.
you can follow the freecodecamp curriculum at freecodecamp.org/learn
if you are searching for a group to work together you will need to search it yourself. In the forum there are a few groups each month formed. You can try using the forum search function.