Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,092
    Thanks
    15
    Thanked 1 Time in 1 Post

    Unhappy javascript calendar won't appear unless HTML is commented out?

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-gb">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>PiccoNet</title>
    </head>
    <body>
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    	<td valign="top">
    		<div class="pageheader">
    			<div class="pageheaderleft">
    				<h1>Administration</h1>
    				<div id="tabs">
    					<ul>
    						<li><a href="/system/adm2.pl" title="Main Menu">Main Menu</a></li>
    						<li class="here"><a href="?action=findc" title="C">C</a></li>
    						<li><a href="?action=find" title="I">I</a></li>
    						<li><a href="?action=showc" title="Groups">Groups</a></li>
    						<li><a href="?action=special" title="Specials">Specials</a></li>
    						<li><a href="?action=pricec" title="Price C">Price C</a></li>
    						<li><a href="?action=upload" title="Image">Image</a></li>
    					</ul>
    				</div>
    			</div>
    <!--
    WORKS WHEN THIS IS OUT?!??
    			<div class="pageheaderright">
    				<form method="GET" action="/system/ch.pl">
    					Page #<input type="text" name="page" value="978" size="5">
    					<input type="submit" value="Go">
    				</form>
    			</div>
    -->
    		</div>
    
    			<p class="bread"><img src="/images/breadarrow.gif" width="14" height="9" alt="&gt;"><a href="/system/adm2.pl">Main</a></p>
    
    			<script language="JavaScript" src="CalendarPopup.js"></script>
    			
    			<script language="JavaScript">
    			var now = new Date();
    			var cal = new CalendarPopup("calendar");
    			cal.addDisabledDates(null, formatDate(now, "yyyy-MM-dd"));
    			cal.offsetX = 90;
    			cal.offsetY = 20;
    			document.write(getCalendarStyles());
    			</script>        
    
    		<!-- for the calendar -->
    		<div id="calendar" style="position:absolute; visibility:hidden; background-color:white; layer-background-color:white;"></div>
                                
    		<h2 style="margin-bottom: 0">Balance Calculator</h2>
    		
    		<div class="formback">
    			<form style="margin: 0;">
    			<table cellspacing="2" cellpadding="2" class="formtable"><tr>
    				<td class="formlabel">Start Date&nbsp;<span class="formrequired">*</span></td>
    		
    				<td class="formfield"><input type="text" name="date" id="date" value="dd/mm/yyyy" tabindex="3" style="width: 180px;" autocomplete="off" onclick="cal.select(document.forms[0].date,'date','dd/MM/yyyy'); return false;" onfocus="cal.select(document.forms[0].date,'date','dd/MM/yyyy'); return false;"></td>
    			</tr><tr>
    				<td class="formlabel">&nbsp;</td>
    				<td class="formfield"></td>
    			</tr>
    			</table>
    			</form>
    		</div>
    	</td>
    </tr>
    </table>
    </body>
    </html>
    Any idea why, with this code the js pop-up won't appear unless the code that i have commented out is commented out?
    Help appreciated.
    Picco

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Well, without seeing the code, I'm guessing it is assuming something about a form.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nothing is jumping out at me. Can you post a link to the failing version?

    david_kw

  • #4
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,092
    Thanks
    15
    Thanked 1 Time in 1 Post
    turned out it was the
    Code:
    document.forms[0].date
    call on my onclick. I used forms[0] instead of forms[1]. I know it's old school code anyway now, need to get it changed to document.getElementById.

    Picco


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •