Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

display php files

12 views
Skip to first unread message

MMZ

unread,
May 17, 2013, 3:29:15 PM5/17/13
to
I have some drop down menu options of php files and want to display them on the same page when user selects and click on view button but I don't know how to complete my code :


<select id="report" >
<?php

echo "<option value=\"".data_summary.".php\">--Select--</option>";
echo "<option value=\"".data_summary.".php\">Data Summary</option>";
echo "<option value=\"".outputs_reports.".php\">Outputs reports</option>";
echo "<option value=\"".outcomes_reports.".php\">Outcomes reports</option>";
echo "<option value=\"".sroi_reports.".php\">SROI reports</option>";
?>

</select>

<button onclick="view()">View</button>
<hr />
<div id="pdf">
<script type="text/javascript">
function view()
{

var e = document.getElementById("report");
var str = e.options[e.selectedIndex].value;

Shahzeb Farooq Chohan

unread,
May 17, 2013, 5:13:32 PM5/17/13
to
just create a div where u want to display the result of that page and ajax will play the trick for you
Here is how
function view()
{

var e = document.getElementById("report");
var str = e.options[e.selectedIndex].value;

if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", str, true);
xmlhttp.send();
0 new messages