Call javascript from php in while loop
<p>I hope someone can help me, I've been struggling, I have a from and within the form is table which has columns.  It retrieves the data from a Mysql table.  In column 2 it displays the current information and in column 3 it displays the form options to update the values, eg:</p>

<pre><code>First name:  John  [Form field to update]
Date of birth: 1970-01-01 [form field to update]
</code></pre>

<p>I'm specifically struggling to get the java script functioning for the popup calendar.  If I run it from html it works fine but when I do it within php I can't get it to run because it displays the form within a while loop:</p>

<pre><code>&lt;head&gt;
   &lt;script src="datetimepicker_css.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php

.....

$sql2="SELECT * FROM em_detail WHERE id = '$data1'";
$result2=mysql_query($sql2);

echo "&lt;form action='upd_emp.php' method=post&gt;";

while($row2 = mysql_fetch_assoc($result2)) {
$id_2 = $row2['id'] ;
.....

echo "&lt;tr&gt;";
echo "&lt;td height=35px&gt;&lt;strong&gt;Date of Birth: &lt;/strong&gt;&lt;/td&gt;";
echo "&lt;td&gt;$dob_2&lt;/td&gt;";
echo "&lt;td&gt;&lt;input size=30 type=Text name=dob id=demo1/&gt;&lt;/td&gt;";
echo "&lt;td align=left&gt;&lt;img src=images/cal.gif onclick=javascript:NewCssCal('demo1') style=cursor:pointer/&gt;&lt;/td&gt;";
echo "      &lt;/tr&gt;";
</code></pre>
