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
Solved

how to make onsubmit disable=false;

Posted on 2008-10-07
1
615 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
1 Comment
 
LVL 82

Accepted Solution

by:
hielo earned 500 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

856 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