Link to home
Start Free TrialLog in
Avatar of chewonthat
chewonthat

asked on

date text field resets on click back

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>
Avatar of marko020397
marko020397

I believe the problem is in your date popup control. It resets the date whenever the user comes to the page.
ASKER CERTIFIED SOLUTION
Avatar of carchitect
carchitect

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chewonthat

ASKER

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?
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>
i'v been fooling around with it awhile and your definately on the right track
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>
i am sorry could not respond to ur comments as my hotmail account is not working...
sorry for the delay...
regards
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>