Solved

how to make onsubmit disable=false;

Posted on 2008-10-07
1
602 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now