I am trying to update the value which is stored in a particular part of my page by using the getElementsById method, followed by calling a function to update the field. However, I don’t know how to do this. The relevant parts of my code are as follows:
Expand|Select|Wrap|Line Numbers
- function text(t)
- {
- return document.createTextNode(t);
- }
- function start(){
- var oHelloText = text(getQuestion()); //the getQuestion method returns a string from an array
- oHelloText.id = "test";
- }
- function updateDetails()
- {
- document.getElementById('test') = text(getQuestion());
- }
Unsurprisingly, this doesn’t work.
Any advice?