Board Logo

calendar with array of elements
ywh - 9/2/2008 at 06:44 PM

I have the calendar3 working if I select one record (row).
If there are more than one row, each row has a calendar by the date box. I got "Error calling the calendar: prrameter specificed is not valid target control." The calendar won't pop-up. Thanks for any help. date field......
<input type="text" size="10" name="checkin_dates[]" value="'.$query['ro_checkin'].'" readonly="readonly"><a href="javascript:cal6.popup();"><img src="images/calendar/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>

......script after the </form>......
echo '<script language="JavaScript">'.'var cal6 = new calendar3(document.forms['userform'].elements'checkin_dates[]']);'. 'cal6.year_scroll = false;'.'cal6.time_comp = false;'.'</script>';

ywh - 9/3/2008 at 11:47 AM

Just a note,
My date field is inside the loop:
if ($result && mysql_num_rows($result)) {
while($query = mysql_fetch_array($result)) {

My script is only called once in the end of the function after the </form>.
echo '<script language="JavaScript">'.
'var cal6 = new calendar3(document.forms['userform'].elements['checkin_dates[]']);'.
'cal6.year_scroll = false;'.
'cal6.time_comp = false;'.

I am not sure if elements['checkin_dates[]'] is the correct syntax. It works for submitting one record, but not multiple records.

ywh - 9/19/2008 at 01:49 PM

I was able to get it to work for multiple calendars on a page and each has a reset date icon.
I would rather have the reset icon on the calendar.html, but for now, the below does what I need.

echo "<form name='userform' method='POST' action='checkin.php'>";
//table starts here, not show the detailed code
if ($result && mysql_num_rows($result)) {
while($query = mysql_fetch_array($result)) {
'|<input type="text" size="10" id='.$rows.' name="checkin_dates['.$rows.']" value="'.$query['checkin'].'" readonly="readonly"><a href="javascript:cal'.$rows.'.popup();"><img src="images/calendar/cal.gif" width="16" height="16" border="0" alt="Click here to select the date"></a><img src="images/calendar/reset.gif" onclick="document.getElementById(''.$rows.'').value=''" alt="Clear date">'.

//table ends here
echo "</form>";

for ($i=0; $i<$rows; $i++) {
echo '<script language="JavaScript">'.
'var cal'.$i.' = new calendar3(document.forms['userform'].elements['checkin_dates['.$i.']']);'.
'cal'.$i.'.year_scroll = false;'.
'cal'.$i.'.time_comp = false;'.

Back to forum: