August 16, 2010

Continuing to hide HTML input fields when page refreshes?

Question by John M

On a HTML page there is a filter section consistenting of various drop-downs and textboxes. When the ‘type_of_report’ drop-down is selected the ‘onchange’ event will hide all the non-relevant inputs for that ‘type_of_report’. The filter criteria is preserved via GET (which I retrieve via PHP $_GET).

The problem is that when I submit the form (run the report) the ‘hidden’ fields re-appear when the page refreshes.

How do I keep the non-relevant input fields hidden when the page refreshes?

NOTE: I am using jQuery (1.4.2) to hide the fields.

UPDATE1:

Final abbreviated solution (based on feedback) looks like this:

<?php
$report_type = $_GET['report_type'];
?>
<html>
<head>
   <!-- hiding/unhiding based on report type -->
   <script type="text/javascript" src="hide.js"></script>
</head>
<body onLoad="hideall('<?php echo"$report_type"; ?>');">

...rest of code

Answer by Starx

Setup a session variables to keep the status of the drop down boxes. And while you are loading it in the view port… filter them using the session variable. It should solve your problem.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!