Page 1 of 1

Simple Javascript compatiblity issue with IE

Posted: Mon Feb 16, 2009 12:16 am
by sokka888
Hi experts,

I have a simple javascript that takes no of days (in numeric) in a free text box and adds the days to the current date and creates a reminder date.

Here is the JS and code

javascript:

Code: Select all

function RemindMe()
{
    var joomlaid = "<?=$joomlaid?>";
    
    if (joomlaid == 0 ) {   
        alert('Please login before continuing. If you have not registered please register now for B1G1 BUSINESS');
    }
    else{
        var textremdays = document.screen1Form.reminderDays.value; 
        var validremdays = textremdays * 1;
 
        var PageName = "2"; 
 
        if((txtProduct!="") && (textremdays!="") && (textremdays<60) && (textremdays!=0) && !(isNaN(validremdays)) ){
 
                var paramString=txtProduct+"|"+txtRefCode+"|"+textremdays+"|"+PageName+"|"+joomlaid;
 
            //redirect to Save page
                var urlstr="<?=$this_site_domain?>development/b1g1f/partnership/partnering_Contribution_save_set.php?paramString="+escape(paramString);
                window.location=urlstr;
        }
        else if(txtProduct==""){
            alert('Please Enter the Product Name!');
            document.screen1Form.productService.focus();
        } 
        else { //if((textremdays<60) || (textremdays=="") || (isNaN(validremdays)) )
            alert('Please Enter a valid reminder day not be more than 60 days and it must be numerical values');
            document.screen1Form.reminderDays.focus();
        }   
     } 
}
 
HTML:

Code: Select all

         
<tr>
            <td valign="middle" class="tblPad5 tblLtPad"><label>
              <input type="checkbox" name="checkbox" value="checkbox" checked="checked" />
              Send me an email reminder in </label>
              <label> 
              <input name="reminderDays" type="text" size="3" maxlength="2" value="5" onChange="ReminderDaysValue(this)" />
              days.</label></td>
            <td align="right" valign="top" class="tblPad5 tblLtPad"><a href="#" onClick='RemindMe(this.form)'><img  src="../../../images/Remind-Me.jpg" name="remind-me" border="0" id="remind-me" /></a></td>
          </tr>
 

Action page code:

Code: Select all

 
$paramList = urldecode($_GET["paramString"]);
 
$token = strtok($paramList,"|");
 
while ($token !== false){
    if(strlen($BussProduct) == 0 )  {
            $BussProduct=$token;
    }
    elseif(strlen($ReffCode) == 0 ) {
            $ReffCode=$token;
    }
    elseif(strlen($remdays) == 0 )  {
            $remdays=$token;
    }
    elseif(strlen($PageNo) == 0 )   {
            $PageNo=$token;
    }
    elseif(strlen($joomlaqurryid) == 0 )    {
            $joomlaqurryid=$token;
    }
    $token = strtok("|");
}
 
 
 function addTime($hours=0, $minutes=0, $seconds=0, $months=0, $days=0, $years=0) 
 { 
  $totalHours = date("H") + $hours; 
  $totalMinutes = date("i") + $minutes; 
  $totalSeconds = date("s") + $seconds; 
  $totalMonths = date("m") + $months; 
  $totalDays = date("d") + $days; 
  $totalYears = date("Y") + $years; 
  $timeStamp = mktime($totalHours, $totalMinutes, $totalSeconds, $totalMonths, $totalDays, $totalYears); 
 
  $myTime = date("Y-m-d", $timeStamp); 
 
  return $myTime;   
 } 
 
    $RemDate = addTime(0,0,0,0,$remdays,0);
 
 
This javaceript works fine on FireFox, but fails on IE. IE just adds 2 days to the current date no matter what we enter in the text field.

Can you show me how to fix this please?

Thanks
Sokka