?
Solved

how to make onsubmit disable=false;

Posted on 2008-10-07
1
Medium Priority
?
631 Views
Last Modified: 2013-12-12
Hellp experts
I have a timed multiple choice test, where each question is set with radio buttons.
I also have a timeout function which disables the radio buttons when the time runs out, so that the user can not edit the answers or enter new answers.

However, when the user clicks the submit button at the end, I want to pass the answers to the database.
In other words I need to achieve; onSubmit disabled=false;

Could anyone tell me how to do this. If I need to add this to the <Form.......      > element, what is the syntax for doing this?

Here is the Javascript code for disabling the radio button at timeout:

-------------------

script type="text/javascript">
      window.onload=initeng;
      function initeng(){
            var mineng=15;
            setTimeout("engPage()", 1000*60*mineng );
      }
      function engPage(){
            //assuming you have <form id="English1"...>
            var f = document.getElementById("English1");
            for( var i=0; i < f.elements.length; ++i)
            {      if(String(f.elements[i].type).toLowerCase() != "submit" )
                     {
                           f.elements[i].style.color="#aaaaaa";
                        f.elements[i].disabled=true;
                        }
      }
      }
</script>
0
Comment
Question by:Erikal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22664698
On what you posted above you do NOT need:
f.elements[i].style.color="#aaaaaa";

when the element is disabled, it will be grayed out by default.

as for re-enabling, modify your form tag to:

<form onsubmit="return sendIt(this)"...> 
then use:
function sendIt(f) {
for( var i=0; i < f.elements.length; ++i)
 f.elements[i].disabled=false;
return true;
}

Open in new window

0

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question