0

print string textbox

string is not being printed <input type="text" disabled placeholder="Meeting Link" name="f"> <button type="button" id="mybtn">Generate Link</button><br> document.getElementById("mybtn").onclick = function() { var meet = [ 'https://meet.google.com/ogp-urbq-hzc', 'https://meet.google.com/ogp-urbq-hzc', 'https://meet.google.com/ogp-urbq-hzc', 'https://meet.google.com/ogp-urbq-hzc', 'https://meet.google.com/ogp-urbq-hzc' ]; var m = Math.floor(Math.random()*5); //console.log(m); //console.log(meet[m]); var meet_link = meet[m]; document.getElementsByName('f')[0].value = meet_link; } https://www.sololearn.com/compiler-playground/WWrL5Y0EeHQM

17th Dec 2022, 5:23 PM
Zane Vijay Falcao
Zane Vijay Falcao - avatar
2 Answers
+ 3
Zane Vijay Falcao Instead of pasting the code in the question description, add a link to your code in Code Playground - use "+" button. This way, we avoid copying twice, possibly causing differences, and we can test and debug your code.
18th Dec 2022, 1:48 AM
Emerson Prado
Emerson Prado - avatar
+ 1
As I can see when I click at button, some link is placed as value for input field. What are you trying to do? As I can see code works Also if you are typing this code on sololearn, and you place js code in js tab. You will have problem,because js code is loaded before html code, so elements what you are selecting don't exist jet. So solution for this is to wrap js code inside: window.onload = () => { // your code here } what will run code when document is loaded
17th Dec 2022, 11:51 PM
PanicS
PanicS - avatar