21 January, 2010

JavaScript passing value to HTML in same page

As mentioned in the previous post Generate a random number from website. There is a variable generator the JavaScript. How to pass this value to an   element of the same page? 
We use:   
document.test.result.value = generator;
test is the form name in the same page's HTML, result is an input element in this form, so this sentence means to pass the value of the variable generator to the input element result in form test.
Then, we can use Python to revoke the element's value for other use.

3 comments:

Lawrence said...

Spent about one and half hours to search the solution, finally found that line just in my code.
Even found "document.getElementByID", but it still not solve my problem.
Just for reference, this line could be helpful in future.

Anonymous said...

Using OpenID.........

Anonymous said...

Another OpenID........