CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2009
    Posts
    3

    Button only works once

    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

  2. #2
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    Re: Button only works once

    what method works once? more code please
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that I’m 64-bit and my blanket is 32-bit and I couldn’t cover myself with it, so I’ve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

  3. #3
    Join Date
    Apr 2009
    Posts
    3

    Re: Button only works once

    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...?

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: Button only works once

    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.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Apr 2009
    Posts
    3

    Re: Button only works once

    error console says getScore is not a function :F

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: Button only works once

    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.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured