Click to See Complete Forum and Search --> : Button only works once
pgTips
April 17th, 2009, 07:46 PM
I have a button which is created in a function (and re-created each time that function is called) and displayed in a div.innerHTML along with a lot of other HTML code including radio buttons.
<input type=\"button\" id=\"saveButton\" value=\"save\" onclick=\"getScore()\">
I've confirmed that the method is only called the once (alert statement at the beginning), any ideas why it only works once and how to fix this? Is there a way to set a button to be unclicked if for some reason the button made stay as clicked/inactive?
Thanks for any help
Xeel
April 17th, 2009, 07:57 PM
what method works once? more code please
pgTips
April 17th, 2009, 08:19 PM
Erm, there's an issue with plagiarism with placing the full code :s and our uni will use software to compare if others come across this post.
I have a multiple choice quiz in an XML file and previously I return a particular question using a servlet.
With this question (which is displayed in a different div along with answers and appropriate radio buttons) I have a button to save the answer (shown above). This invokes the getScore() function.
The get score function accesses group of radiobuttons (document.getElementsByName) and then iterates over them to see which (if any) has been checked. When the checked button is found then attributes like the id & value are stored in variables. Another servlet is then called to store this response. It returns an xml/application with the new score from the quiz.
this new score is displayed in a <div id="score"></div> via it's .innerHTML
Does this explanation give any hint or...?
PeejAvery
April 17th, 2009, 11:38 PM
Well, then there really isn't any way to help you. That's like telling Edison to invent a better filament but not giving him any money or resources to make it.
Why don't you check for errors using Firefox's Error Console? That should give you some insight.
pgTips
April 18th, 2009, 05:02 AM
error console says getScore is not a function :F
PeejAvery
April 18th, 2009, 06:58 PM
Then, I would assume you are creating that function dynamically. If that is the case, you have to find out what in your code is also overwriting it.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.