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

x
?
Solved

php, javascript form input freeze at timeout

Posted on 2008-10-07
8
Medium Priority
?
503 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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

656 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