Board Logo

Can use calendar in normal but not in array, please help! SOLVED!
Porsche.V - 5/28/2008 at 10:40 AM

hi, when i use the calendar in normal htlm:

<form id="form1" name="form1" method="post">
<p>Insert Date:
<input type="text" size= '12' name="txt_data" id="txt_data" value="">
<a href="javascript:cal1.popup();"><img src="imagens/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>
</p>
<p>
<input type="submit" name="butao_dia" id="butao_dia" value="Dia" />
<input type="submit" name="butao_semana" id="butao_semana" value="Semana" />
</p>
</form>
<script language="JavaScript">
var cal1 = new calendar1(document.forms['form1'].elements['txt_data']);
cal1.year_scroll = true;
cal1.time_comp = false;
</script>

if works very well, but, in the same page i have php, and i am listing form the db some information of a production line, and, in each one of the results, i have a field for date, that i wanted to be filled through the calendar. but it doesn't work, sometimes i get the "error calling the calendar: no target control specified":

print "<form name='listofrequests' align='center' valign='top' method='post' action='update.php'>n";

while ($orders = mssql_fetch_array($result)) {
print "<input type='hidden' name='iditem[$i]' value='{$orders['iditem']}' />";
.
.
.
print "<table><tr bgcolor={$bgcolor}><td width='30'><input type='checkbox' name='acceptedd[$i]' /></td><tdwidth='100'> {$orders['idmodelo']} </td></td><td width='150'>{$orders['idproduto']} </td><td width='50'>{$orders['idpele']} </td><td width='30'>{$orders['cor']} </td><tdwidth='40'>{$orders['ordemfabrico']} </td><td width='30'>{$orders['qtd']} </td><td width='80'>{$orders['dt']}</td><td><input type='text' size='12' name='prevista[$i]'value='{$orders['dtpropostaentrega']}'><a href='javascript:cal2.popup();'><img src='imagens/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a></td></table>n";

++$i;
}
print "</form>";
print "<script language='JavaScript'>";
print "var cal2 = new calendar1(document.forms['listofrequests'].elements['prevista[$i]']);";
print "cal1.year_scroll = true;";
print "cal1.time_comp = false;";
print "</script>";

i am using the arrays because i need them to update some date to the lines that have the checkbox checked..

now, if i put like this:

print "<script language='JavaScript'>";
print "var cal2 = new calendar1(document.forms['listofrequests'].elements['prevista[$i]']);";
print "cal1.year_scroll = true;";
print "cal1.time_comp = false;";
print "</script>";
++$i;
}
print "</form>"

before /form, the calendar opens and puts the date in the field, but only in the last line. (there is a calendar in the end of each line, the ideia is for each line open the calendar and put the date in the date field of that line) and if there 10 lines od results, and i open the calendar from the 1st line it puts the date in the 10th field..

hope you can help me..

thanks a lot

SOLUTION:

<input type='text' size='12' name='prevista[$i]' value='{$orders['dtpropostaentrega']}'>

<a href='javascript: cal$i.popup() ;'>

<img src='imagens/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the
date'></a></td></table>n";

print "<script language='JavaScript'>";

print "var cal$i = new calendar1(document.forms['listofrequests'].elements['prevista[$i]']);";

print "cal1.year_scroll = true;";
print "cal1.time_comp = false;";
print "</script>";


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/