filter Table with Dropdown list data onchange

sh shoaib 22 Jul, 2010
Hi,


I have a Table which should be filtred with the Dropdown list onchange.

I have no Idea to do this with chronoform. I have tried with the following coding it is not working.

Kindly help me.

I used this coding in Form HTML:


<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Donation Year</label>
    <select class="cf_inputbox" id="select_2" size="1" title=""  name="Donation_For_Year" onchange = compfuntion() >
<option value="">Choose Option</option>
    

<?php 
$result = mysql_query( "SELECT Project_Year FROM Project_Year" )
or die("SELECT Error: ".mysql_error());

while ($line = mysql_fetch_array($result)) {
print ("<OPTION value=".$line[0].">$line[0]</OPTION>"); }
?>
    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>


This is the coding used in the Javascript


function compfuntion()
{
<?php
print "<br></br>";
print "<br></br>";
print "<br></br>";
print "<br></br>";
print "<h3> Projects in Progress </h3>";

$result = mysql_query( "SELECT p.Project_Name,p.Activity_Name,v.Village, v.Mandal, v.District, v.State,p.Estimated_Cost_Rs,p.Funds_Mobilized_Dollar,DATE_FORMAT(p.Expected_Start_Date,'%m-%d-%Y'), DATE_FORMAT(p.Expected_Complete_Date,'%m-%d-%Y')   FROM Project as p 
JOIN Project_Location as v ON v.fabrik_internal_id = p.Village WHERE p.Status_Id ='In Progress'" ) 

or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=950 border=0>\n";
print "<th>Project Name</th>";
print "<th>Activity Name</th>";
print "<th>Village</th>";
print "<th>Mandal</th>";
print "<th>District</th>";
print "<th>State</th>";
print "<th>Estimated Cost</th>";
print "<th>Funds Mobilized</th>";
//print "<th>Still Funds Required</th>";
print "<th>Start Date</th>";
print "<th>Estimated Completion Date</th>";
while ($get_info = mysql_fetch_row($result))
{

print "<tr>\n";
foreach ($get_info as $field)

print "\t <td><font face=arial size=1/>$field</font></td> \n ";



print "</tr>\n";

}
print "</table>\n";
?>
}



Regards,
Shoaib.
sh shoaib 24 Jul, 2010
Hi,


Friendly Bump. Is the anyone who can help me in this coding.

Regars,
shoaib.
Gr GreyHead 26 Jul, 2010
Hi Shoaib,

First off, this looks like a ChronoForms question but it's in the ChronoConnectivity forum. Should I move it?

Secondly, you can't put PHP inside a JavaScript function wrapper and expect anything useful to happen. PHP is executed on the server before the form loads; JavaScript is executed in the browser after the form has loaded

From the code it looks as though you want to show a filtered list of projects. If so, then ChronoConnectivity is the right tool to use. See the examples in the forums here about using filters with a ChronoConenctivity listing.

Bob
This topic is locked and no more replies can be posted.