?
Solved

date text field resets on click back

Posted on 2003-02-19
8
Medium Priority
?
358 Views
Last Modified: 2006-11-17
i have a form.php that is sent to a form handler.php where the user can look over the data before submission.  if the user want's to change/alter the data then he can click back.  the only problem is that the date input is reset and no longer there, making him have to use the popup date calendar all over agan; that is if he even notices that the date has reset since all the other inputs are still there.

i use this at the top of the form processor.php if it helps
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix for the same problem

i have included below the form.php date field and calander pop ref, if u need more let me know.  also if possible i would like it to work in all browswers.

good luck,


<input name="date" type=text id="date" onFocus="javascript:blur();" value="click icon to get date>" size="22" readonly>
<a href="javascript:;" onClick="KW_doCalendar('txtName',0)"><img src="help.gif" width="24" height="24" border="0"></a>
0
Comment
Question by:chewonthat
[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
  • 5
  • 2
8 Comments
 
LVL 4

Expert Comment

by:marko020397
ID: 7985901
I believe the problem is in your date popup control. It resets the date whenever the user comes to the page.
0
 
LVL 6

Accepted Solution

by:
carchitect earned 200 total points
ID: 7985996
yes it will reset as the solutio is
when you execute your form first time.... use some session field as


use this code before going to main form.......
<?
session_start();
$ses_date="Click icon to get date";
session_register('ses_date');
?>


Main Form.......
<?
session_start();
?>
<input name="date" type=text id="date" onFocus="javascript:blur();" value="<?=$_SESSION['ses_date']?>" size="22" readonly>
<a href="javascript:;" onClick="KW_doCalendar('txtName',0)"><img src="help.gif" width="24" height="24" border="0"></a>


Form Handler.........
Now here set
<?
session_start();
$_SESSION['ses_date']=$_POST['date'];
?>
Then...Form Handler Code.....



Now.......even if you go back to main form...now your main from will contain the date which user selected when he entered form data fro the first time....



Regards
0
 

Author Comment

by:chewonthat
ID: 7990959
hi, thanks, i tried it in the page before my form and got the following:
Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

i wouldn't have a clue how to disable.

is there anyway i can just assign the value in the form.php (as you call it Main form)?  instead of putting code before the main form?
0
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 

Author Comment

by:chewonthat
ID: 7991018
this might help, here is my formhandler
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix

         
// Get the user's input from the form
     $date = $_POST['date'];


// Create a new Session Value
  session_register('date');
       
// Register the input with the value
  $_SESSION['date'] = $date;

         
$enter_to_db = <<<PUT_IN
<?
PUT_IN;

          // save all the globals to a text file...
        foreach ($_POST as $word => $val) {
           $enter_to_db .= "\$$word:::$val\n";
        }

      // save all the globals to a text file...
        foreach ($_GET as $word => $val) {
           $enter_to_db .= "\$$word:::$val\n";
        }

$enter_to_db .= <<<PUT_IN
?>
PUT_IN;

        $rand = rand(1,999);

        $put = @fopen("$rand.ses", "w+");
        fputs ($put, $enter_to_db);
        fclose($put);

       
// Display the sssion information:

<body>
<form action="https://www.paypal.com/cgi-bin/webscr" method=POST id=form1 name=form1>
 the date of your call, <strong><? echo $_SESSION['date']; ?>            
</form>
</body>
0
 

Author Comment

by:chewonthat
ID: 7991073
i'v been fooling around with it awhile and your definately on the right track
0
 

Author Comment

by:chewonthat
ID: 7991157
took me awhile but i got it thanks to your lead.  i gues you have to have the php before form.php, won't this just fill up my server space with useless sessions data, if  users just want's to look at the form?

pre main form

<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
$date="Click icon to get date";

// Create a new Session Value
 session_register('date');
     
// Register the input with the value
 $_SESSION['date'] = $date;

main fom

<input name="date" type=text id="date" STYLE="color:gray"
onFocus="javascript:blur();" onMouseOut="this.style.color='black'"
value="<? echo $_SESSION['date']; ?>"  size="22" readonly>
0
 
LVL 6

Expert Comment

by:carchitect
ID: 8031920
i am sorry could not respond to ur comments as my hotmail account is not working...
sorry for the delay...
regards
0
 

Author Comment

by:chewonthat
ID: 8067435
no problem, now a new problem has come up, (of course) i took your advice and it works fine for normal inputs but how do i keep radio buttons and drop down lists from reseting on click 'back'

<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
$date="Click icon to get date";

// Create a new Session Value
session_register('date');
     
// Register the input with the value
$_SESSION['date'] = $date;

main fom

<input name="date" type=text id="date" STYLE="color:gray"
onFocus="javascript:blur();" onMouseOut="this.style.color='black'"
value="<? echo $_SESSION['date']; ?>"  size="22" readonly>
<input type="radio" value="day" checked name="option">
        10am-12pm through 1-4pm
        <input type="radio" value="evening" name="option">
        5-10pm</font> </td>
<select name="hour" size="1" id="select6">
          <option>05am</option>
          <option>06am</option>
          <option>07am</option>
          <option>08am</option>
          <option>09am</option>
          <option>10am</option>
          <option>11am</option>
          <option>12pm</option>
          <option>01pm</option>
          <option>02pm</option>
          <option>03pm</option>
          <option>04pm</option>
          <option>05pm</option>
          <option>06pm</option>
          <option>07pm</option>
          <option>08pm</option>
          <option>09pm</option>
        </select>
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

762 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