I am using this code to display calender
This runs on IE but not on Firefox

<table border="0" cellpadding="0" cellspacing="0" style="height: 150px; border-collapse: collapse" width="100%" class="searchBox">
      <form action="index.php?view=search2" method="post" name="SearchForm" onSubmit="Javascript: return checkSearchForm();">
	  <tr>
        <td colspan="2" valign="top">
		<table align="center" border="0" cellpadding="0" cellspacing="0"  width="100%" class="normalHeading3">
                                  <tr>
                                    <td valign="top" width="13">
                                    <img border="0" vspace="10" hspace="10" width="13" height="13" alt=""></td>
                                    <td valign="top" class="normalHeading3">
                                    <p style="margin-left: 5px; margin-top: 7px; margin-bottom: 0px" align="left">
                                    Search Property </td>
                                  </tr>
                                </table>
		</td>
      </tr>
      <tr>
        <td width="35%">
		<p style="margin-left: 10px; margin-top: 5px; margin-bottom: 5px" align="left">
           Arrival</p></td>
        <td>
		<p style="margin-top: 5px; margin-bottom: 5px" align="left">
										  <input type="text" name="arrival" value="<?=$arrival;?>" size="20" style="width:100px" class="inputBox"/>
					  						<script type="text/javascript" language="javascript">
											
											if(!document.layers) {
											document.write('<a href="Javascript:void(0);" onclick="popUpCalendar(SearchForm.arrival,SearchForm.arrival, SearchForm.departure, \'yyyy-mm-dd\');"><img src="date/cal.gif" border="0" align="absmiddle" alt="Change Date"></a>');
											}
											
                        					</script></p>
		</td>
      </tr>
      <tr>
        <td>
		<p style="margin-left: 10px; margin-top: 5px; margin-bottom: 5px" align="left">
        Departure</p></td>
        <td>
		<p style="margin-top: 5px; margin-bottom: 5px" align="left">
                                            <input type="text" name="departure" value="<?=$departure;?>" size="20" style="width:100px" class="inputBox"/>
                                         <script type="text/javascript" language="javascript">
											
											if (!document.layers) {
											document.write('<a href="Javascript:void(0);" onclick="popUpCalendar(SearchForm.departure, SearchForm.departure, SearchForm.departure, \'yyyy-mm-dd\');"><img src="date/cal.gif" border="0" align="absmiddle" alt="Change Date"></a>');
											}
											
                        					</script></p>
		</td>
      </tr>
      	  
	  <tr> <td height="10"> </td></tr>
	  </form>
    </table>

How to solve it??

Recommended Answers

All 3 Replies

Post in the appropriate forum. This is not a php issue. If it were, the calendar wouldn't work on any browser.

if(!document.layers)

these fragments in the script above check for the browser to NOT be firefox
IF Not DOcument.layers continue = do nothing if document.layers
IE and mozilla based browsers
code sniippets below demonstrate different aproaches to show or hide a layer in IE and firefox

(document.getElementById) ? dom = true : dom = false; // IE check
function hideIt(layer) {
 if (dom) {document.getElementById(layer).style.visibility='hidden';} //ie
 if (document.layers) {document.layers[layer].visibility='hide';} } //firefox
function showIt(layer) {
 if (dom) {document.getElementById(layer).style.visibility='visible';} //ie
 if (document.layers) {document.layers[layer].visibility='show';} } //firefox

second if statement is redundant in each case, at the moment there are only two forms for document model,
slightly different. just enough that the code for one does not work with the other, standards compliance - grump grump grump
not sure why the original was not scripted to run on both, unless the author was only familiar with one
used with

<button onclick='showit("answer");'>Show more info</button>
<div name='answer' style='visibility:hidden;'>
the answer
more text 
<button onclick='hide it("answer");'>hide</button>
</div>
<button onclick='showit("answer2");'>Show more info about problem 2</button>
<div name='answer2' style='visibility:hidden;'>
the second answer answer
more text 
<button onclick='hide it("answer2");'>hide</button>
</div>

example code untested, just pulled it out of the air

I can only assume that the popup calendar defined elsewhare uses the IE Document model (DOM) to display as a hidden layer and or popup onclick, there shouldnt be much to recode the hidden/visible section of the code to be browser independent,(until somebody comes up with another document model) using the scraps above as reference

Have got to the bottom of the zip file,
the javascripts include IE dom,
there are a lot of DOM declaratives
the script may run on both IE and mozilla based browsers. but likely wont
on a non production run of the script edit out the if(!document.layers) { and the matching } and test in both browser platforms
check also if there is another line in the install instructions that specifies if(document.layers) { (no bash)
If the script fails to run there is some serious debugging involved in the existing script

THere are however cross browser compatible calendar scripts for filling date fields
I use this one
http://www.richarea.com/demo/rich_calendar/

No affiliation with the owner developer
no fee for promotion
no guarantee of suitablility given
fully examine and assess before including any suggested material.
My experience of this script is positive

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.