+ 1
Can we print loop output in same page.
Like we have html page inside that we have input tag for taking input from user and that input value is going to be used in loop as well, And after some calculations done by loop the output will be printed next to input in another div in same html page. Is it possible !! Souce code: https://code.sololearn.com/W7gYdfXr455J/?ref=app
18 Respostas
+ 4
Hey there Ashu, here is the fixed code:
https://code.sololearn.com/WsRm6k9V12eA/?ref=app
Just remove the innerHTML from the variable itself and use '+=' instead of '=';
You were overwriting the document again, that's why the result was being shown in a new page!
+ 4
Yes use innerHTML property for that .
+ 3
https://code.sololearn.com/W0AVEua3MZ13/?ref=app
See for sample I had used innerHTML property with functions.
+ 2
Ok just share your source code so that we can modify it
+ 2
Hay Ashu . Arb Rahim Badsa bro has done it for you .
+ 1
Use javascript to get the value from input. Make a variable like
$var=document.getElementById('textbox_id').value
Then use this variable for calculation and then return it's value in the same textbox or into another one.
+ 1
Are you using any eventlistner?
+ 1
Use js event like onclick ....then use innerhtml then that function will run with automatically changed value on the same page
+ 1
You can also do this you can store the text field value in variable ... Do you calculation store in new variable, create a onclick or oninput function then return it's value using the document.getelementbyid('').value= new variable value;
Share your code if you still have problem we can help you out
+ 1
Thank you guys.
#Auysh
#Vishal
#Rahim
+ 1
Thank you so much bro
#Arb rahim badsa
0
But after using InnerHTML property
Output print in another page not in same page bro.
I am looking that output should print in a same page in one particular div.
#Ayush. ks
0
How should I return loop output,
In my case it only print last line of loop.
#vishal
0
Yes bro i use eventListner Onclick.
0
Ok wait I will show my work
0
https://code.sololearn.com/W7gYdfXr455J/?ref=app
This is my code.
0
Got It... So you're trying to return a whole sequence of table in your html box
0
@Arb Rahim. Not thought of that actually.
I tried using an array to store the value of the loop, it worked but retrieving all the values in a same textbox was the challenge. It was only retrieving the final value. But somehow it worked. But you did great work. Appreciated.