answersLogoWhite

0

If your text box has the ID foo and your JavaScript variable is named bar, then you can use the following code to put the value of the variable into the text box:

document.getElementById("foo").value=bar;

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Which HTML tag is used to indicate to the web browser that the HTML page contains a javascript program?

Easy one. <script type="text/javascript"></script>.


How do you put java script into HTML?

Javascript inside html <html> <head> <script type="text/javascript" language="javascript"> // Java script code here </script> <body> // html code here </body> </html> Via External Link: <html> <head> <script type="text/javascript" language="javascript" src="location of js file"> </script> <body> // html code here </body> </html>


What is innerHTML in javascript?

innerHTML is often used in javasript to change the value already present in html tags. For eg The following code will change the text on button click <html> <head> <script type="text/javascript"> function changeText() { document.getElementById("changeText").innerHTML = "I am fine thank you. How about you?" } </script> </head> <body> <div id="changeText"> Hello! How are you? </div> <input type="button" value="Change Text" id="button_1" onclick="changeText()" /> </body> </html>


Is this Javascript Code Correct?

<html> <head> <script type="text/javascript"> // Start with value 1 var StudentCurrentID = 1 function Dissplay(StudentCurrentID) { document.write ("<p>Student Number"+ StudentCurrentID +":<INPUT TYPE=TEXT NAME=Student"+StudentCurrentID+"name></p… StudentCurrentID++} </script> </head> <body><script type="text/javascript"> StudentsTotalNum = Prompt("Enter Total Number of Students"); return StudentsTotalNum; </script> <form name=StudentsNames> <script type="text/javascript"> for StudentCurrentID < StudentTotalNum { Dissplay(StudentCurrentID) }; </script> </form> </body> </html>


Javascript programme with one textbox and one button showing table of the given number?

Use the <input type="text" /> tag in HTML and give it an id. Then use document.getElementById(id).value to get that value and use it in a for loop from 1 to 10 and multiply the value by the variable used in the for loop. Then just output that in any way you desire.


How do you make text flash different colours with a delay between each colour with HTML?

You can't due this in HTML. You're going to have to use JavaScript.


Is JavaScript programs compiled into intermediate form and linked to a HTML document?

JavaScript isn't compiled. It's an interpreted language, which means that it's translated into 'computer language' line by line when needed. You can link JavaScript to a HTML document by using the src attribute of the script tag. If you name your external javascript 'test.js', you can inject it into your HTML page by using <script type="text/javascript" src="test.js"></script>.


Calculations in HTML?

HTML is a static language, you cannot do any math using only HTML. To do math, you need a scripting language such as JavaScript. Try this code: <script type="text/javascript"> document.write((2+3)*2); </script> put this in your HTML page and it should display as 10


Create an HTML page which pops up an alert message?

<html> <head> <script type="text/javascript"> function show_alert() { alert("I am an alert box!"); } </script> </head> <body> <input type="button" onclick="show_alert()" value="Show alert box" /> </body> </html>


How do you display the text entered by the user in a html page on the same html pagelike i mean that real time entering the data by the user and displaying the data back to the user what he have enter?

You can do it by referring the input type in javaScript. Then you can get the value by id in the same and display it.


How do you insert a HTML text box in a flash website how to insert HTML text box code in empty text box?

The textarea tag is a part of the form tag and is contained within that and the fieldset tags. A textbox is produced by an inline or external JavaScript.


What is the difference between script and scriptlet?

"script" is an HTML tag used to include JavaScript on a web page. Example: <HTML> <body> <script type="text/javascript"> document.write("hi there"); // javascript interpreted by the browser </script> </body> </HTML> "Scriptlet" is a JSP construct used to include Java in a JSP page. Example: <HTML> <body> <% // this is a scriptlet response.getWriter().write("hi there"); // Java executed on the server %> </body> </HTML> Here the result (an HTML document with the text "hi there") is the same in both cases, but the mechanisms are different - Javascript runs in the browser (any browser), while the JSP scriptlet is executed on the server and needs a server with JSP support. See related links.