Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

DHTML Calendar w/Query String

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
jman
Smarty Rookie


Joined: 14 Apr 2007
Posts: 8

PostPosted: Thu Nov 08, 2007 1:28 pm    Post subject: DHTML Calendar w/Query String Reply with quote

Hi, all, not sure what I'm doing wrong, the jscalendar examples work fine, but in my page, every time I click on the button to get a calendar popup it refreshes the page.

Am using query strings to populate the page (based on a user id) from mySQL, so for example the addressbar might look like:
http://www.mysite.com/folder/?page=mypage&action=dosomething&id=5

And there'd be a form filled with the data for userid 5, but after clicking on the calendar button the page reloads & the addressbar would be

http://www.mysite.com/folder/?page=mypage

Since the action & userid are missing, I now have a blank form.

Had thought the javascript would be updating the form fields without a page reload, but that's not what appears to be happening.

Have verified the page can reach the jscalendar code, the dhtml_calendar plugin is installed correctly, just not sure why it's reloading rather than showing the calendar popup. Any ideas?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Nov 08, 2007 7:09 pm    Post subject: Reply with quote

You might have to show your relevant template code.
Back to top
View user's profile Send private message
jman
Smarty Rookie


Joined: 14 Apr 2007
Posts: 8

PostPosted: Fri Nov 09, 2007 8:20 pm    Post subject: Reply with quote

Sure thing. Just so there's no confusion, here's index.php as well:

<?php
session_start();
require("c:\\cal_test\\smarty\\Smarty.class.php");
$smarty = new Smarty;
$smarty->template_dir = "c:\\cal_test\\smarty\\templates";
$smarty->config_dir = "c:\\cal_test\\smarty\\config";
$smarty->cache_dir = "c:\\cal_test\\smarty\\cache";
$smarty->compile_dir = "c:\\cal_test\\smarty\\templates_c";
$smarty->display("index.tpl");
?>

Inside index.tpl, NOT using the plugin works:

{* Smarty *}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>
Popup Calendar Test Page
</title>
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar.css" title="Calendar">
</head>
<body>
Your Random Number Is: {0|rand:100}
<br>
<br>
<form action="index.php" method="post">
<input name="mytext" id="mytext" type="text">
<br>
<br>
<input name="date" id="date" type="text">
<button id="date_trigger">...</button>
</form>
{literal}
<script>
Calendar.setup({
inputField : "date",
ifFormat : "%m/%d/%Y",
showsTime : false,
button : "date_trigger",
singleClick : false,
step : 1
});
</script>
{/literal}
</body>
</html>


But this does not:
{* Smarty *}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>
Popup Calendar Test Page
</title>
{dhtml_calendar_init src="calendar/calendar.js" setup_src="calendar/calendar-setup.js" lang="calendar/calendar-en.js" css="calendar/calendar.css"}
</head>
<body>
Your Random Number Is: {0|rand:100}
<br>
<br>
<form action="index.php" method="post">
<input name="mytext" id="mytext" type="text">
<br>
<br>
<input name="date" id="date" type="text">
<button id="date_trigger">...</button>
</form>
{dhtml_calendar inputField="date" button="date_trigger" singleClick=false}
</body>
</html>


In the former case I get a popup calendar which populates the desired text box after choosing a date in the popup. In the latter the form gets submitted (the address bar changes from http://site/ to http:/site/index.php)

Using v1.1.5 of the dhtml_calendar plugin, and 1.0 of jscalendar itself (both dl'd fresh again this morning just to make sure the code wasn't corrupt somehow).

Also used the RandomNumberPlugin, just to verify that I wasn't having a problem with the plugin folder itself. If rand.php works (it does), then it seems that dhtml_calendar_init & dhtml_calendar should as well.

Oh, when viewing source using the 2nd method (with the Smarty popup), after the </form>, where I thought the plugin would insert the javascript code that I had to manually put in with the 1st method, instead I see:

<script>
/* <![CDATA[ */
Calendar.setup({"inputField":"date","button":"date_trigger","singleClick":false});
/* ]]> */
</script>

Also tried absolute as well as relative paths to the js code & css in the call to dhtml_calendar_init, that had no effect.

Curiouser & curiouser...
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Nov 13, 2007 7:35 pm    Post subject: Reply with quote

It seems to work for me. Please ensure that all the paths are correct and that the files are accessible by your webserver. For example, your lang= parameter seems to be setup incorrectly in comparison to your working example and the jscalendar default dir layout. That most certainly can cause failure. FWIW, I use Firebug in Firefox to find such problems.

HTH
Back to top
View user's profile Send private message
jman
Smarty Rookie


Joined: 14 Apr 2007
Posts: 8

PostPosted: Sun Nov 18, 2007 4:35 pm    Post subject: Reply with quote

Yeah, I think it was the path to the language file, I'd been moving the js around. It's working fine now.

Go, operator error! Wink Thanks for looking...
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP