Solved

php, javascript form input freeze at timeout

Posted on 2008-10-07
8
494 Views
Last Modified: 2013-12-12
Hello,
OK I running in circles here. That is me not knowing nearly enough about php ,and any other script language for that matter.
On a previous question I asked about disabling the form input fields at timeout. Which worked wonderfully, but what I did not realize is that the disabled inputs would no longer be available for the following php code to work with, unless of course I have missed something again.
The link to the previously closed question is:
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23793573.html

Once the form inputs are disabled and the user clicks the submit button, I need the values of the frozen input fields to be picked up by the php script and processed, so that the results are inserted into the corresponding sql table.

Would I be able to do that and how.

Many thanks
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
  • 4
  • 4
8 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22661384
My apologies, I missed that completely. Use this:

            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].readOnly=true;
                        }
            }
0
 

Author Comment

by:Erikal
ID: 22662271
Yes it works, but yet again I need your help.
The readonly command only works on the text inputs. I have radio buttons in the form as well and radio buttons are still active.
Any suggestions?

Thank you.
0
 

Author Comment

by:Erikal
ID: 22663022
Hi,
I read somewhere that may be it is possible to disable the form alements (all or just the radios), which is what I need. Then, in order to get them passes on to the php, enable them on submit.
If this is true, how would I need to modify the code (would I need another function for changing disable=true to disable=false). Then to activate that function in the <form .............. onSubmit="javascript:enablefunction()> or something like that.

Any suggestions?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 82

Expert Comment

by:hielo
ID: 22663058
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].readOnly=true;
f.elements[i].onclick=function(){return false;};
                        }
            }
0
 

Author Comment

by:Erikal
ID: 22663392
This does not quite work I am afraid.
The onclick=function(){return false;}; just disables the radio buttons altogether. That is fine, but when you click on a radio button in a question it just clears any existing entry on that question. Hence, the record field on the sql table for that question goes blank.
What i mean is, if the user chooses one of the buttons for a given question and decides, after timeout, to edit/change that answer, any exiting answer is just cancelled on that question.
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 22664146
How about this: diable all the elements except the submit. Once the user clicks the submit button, then re-enable all the fields so that the browser sends all the values.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 
<html>
<head>
<title></title>
<script type="text/javascript">
      window.onload=init;
      function init(){
            var minutes=(5/60);
            setTimeout("nextPage()", 1000*60*minutes );
      }
      function nextPage(){
            //assuming you have <form id="theForm"...>
            var f = document.getElementById("theForm");
            for( var i=0; i < f.elements.length; ++i)
            {
		  	if( String(f.elements[i].type).toLowerCase() != "submit" )
                  f.elements[i].disabled=true;
            }
      }
	 function activate(f){
            for( var i=0; i < f.elements.length; ++i)
            {
                  f.elements[i].disabled=false;
            }
	return true;
	}
</script>
 
</head>
<body>
<form id="theForm" onsubmit="return activate(this)">
	<input type="text"/>
	<input type="text"/>
	<input type="text"/>
 
	<input type="submit" />
	
</form>
</body>
</html>

Open in new window

0
 

Author Comment

by:Erikal
ID: 22664609
Yes!
Great! It worked.
many thanks
0
 
LVL 82

Expert Comment

by:hielo
ID: 22669202
you are welcome
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

688 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