[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

how to make onsubmit disable=false;

Posted on 2008-10-07
1
Medium Priority
?
638 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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 how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

649 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