Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open results in a new window

Status
Not open for further replies.

kybby

Programmer
Apr 27, 2005
3
AU
Hi,

I'm using a system of drop down menus to determine which csv file to open the results of. I'm displaying the data of that csv in table on my current page.

Does anybody know a way of parsing all that data into a new window? or a better way of doing this so that the table is opened in a new window.
The new window needs to be plain html.

Thanks in advance,
kybby
 
Link with a target set to _blank or a javascript method window.open. But without seeing what exactly you're doing it is hard to help further.
 
Sorry the code is really long.

What is trying to be created here is a report system for a series of data reports. ATM none of the drop downs are linked, but the results table is viewable using the "view dummy report" button.
Currently when clicked it is hiding the reports table and showing the results table, what I need help on is instead opening the results table in a brand new window.

All help is greatly appreciated, thanks in advance
kybby


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Test Page</title>
</head>


<script Language="JavaScript">


function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = "" ;
myEle.text = "Please Select" ;
controlToPopulate.add(myEle) ;
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = ItemArray[x] ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End Dropdown Box Population

//Page error checking
function valButton(btn) {
var cnt = -1;
for (var i=0; i < btn.length; i++) {
if (btn.checked) {cnt = i; i = btn.length;}
}
if (cnt > -1)
return btn[cnt].value;
else return null;
}
function show_report()
{
if(document.getElementById("ResultsTable").style.display == "block")
{ document.getElementById("ResultsTable").style.display = "none";
document.getElementById("ReportsTable").style.display = "block";}
else
{ document.getElementById("ResultsTable").style.display = "block";
document.getElementById("ReportsTable").style.display = "none";}

}
function toggle_fields()
{
var strReport = valButton(report);
var strRcReport = valButton(CO);
var strPeReport = valButton(PE);


if (strReport=="SpeciesReport")
{ document.getElementById("Sp_sp").style.display = "block";
document.getElementById("Sp_ti").style.display = "block";
document.getElementById("Sp_lo").style.display = "block";
document.getElementById("Sp_view").style.display = "block";
document.getElementById("Sp_down").style.display = "block";}
else
{ document.getElementById("Sp_sp").style.display = "none";
document.getElementById("Sp_ti").style.display = "none";
document.getElementById("Sp_lo").style.display = "none";
document.getElementById("Sp_view").style.display = "none";
document.getElementById("Sp_down").style.display = "none";}

if (strReport == "CountryReport")
{ document.getElementById("Co_co").style.display = "block";
document.getElementById("Co_ti").style.display = "block";
document.getElementById("Co_lo").style.display = "block";
document.getElementById("Co_view").style.display = "block";
document.getElementById("Co_down").style.display = "block";}
else
{ document.getElementById("Co_co").style.display = "none";
document.getElementById("Co_ti").style.display = "none";
document.getElementById("Co_lo").style.display = "none";
document.getElementById("Co_view").style.display = "none";
document.getElementById("Co_down").style.display = "none";}

if (strReport == "PeriodicalReport")
{ document.getElementById("PE1").style.display = "block";
document.getElementById("PE2").style.display = "block";
document.getElementById("PE3").style.display = "block";
document.getElementById("PE4").style.display = "block";
document.getElementById("PE_lo").style.display = "block";
document.getElementById("PE_view").style.display = "block";
document.getElementById("PE_down").style.display = "block";


if (strPeReport == "PeriodMonth")
{ document.getElementById("PE_mm").style.display = "block";
document.getElementById("PE_my").style.display = "block";}
else
{ document.getElementById("PE_mm").style.display = "none";
document.getElementById("PE_my").style.display = "none";
}

if (strPeReport == "PeriodQuarter")
{ document.getElementById("PE_qq").style.display = "block";
document.getElementById("PE_qy").style.display = "block";}
else
{ document.getElementById("PE_qq").style.display = "none";
document.getElementById("PE_qy").style.display = "none";}

if (strPeReport == "PeriodFinancial")
{ document.getElementById("PE_fy").style.display = "block";}
else
{ document.getElementById("PE_fy").style.display = "none";}

if (strPeReport == "PeriodCalender")
{ document.getElementById("PE_cy").style.display = "block";}
else
{ document.getElementById("PE_cy").style.display = "none";}
}
else
{ document.getElementById("PE1").style.display = "none";
document.getElementById("PE2").style.display = "none";
document.getElementById("PE3").style.display = "none";
document.getElementById("PE4").style.display = "none";
document.getElementById("PE_lo").style.display = "none";
document.getElementById("PE_mm").style.display = "none";
document.getElementById("PE_my").style.display = "none";
document.getElementById("PE_qy").style.display = "none";
document.getElementById("PE_qq").style.display = "none";
document.getElementById("PE_fy").style.display = "none";
document.getElementById("PE_cy").style.display = "none";
document.getElementById("PE_view").style.display = "none";
document.getElementById("PE_down").style.display = "none";}

if (strReport == "RegionalReport")
{ document.getElementById("CO1").style.display = "block";
document.getElementById("CO2").style.display = "block";
document.getElementById("RC_pe").style.display = "block";
document.getElementById("RC_view").style.display = "block";
document.getElementById("RC_down").style.display = "block";


if (strRcReport == "RegionalCountry")
{ document.getElementById("RC_co").style.display = "block";
document.getElementById("RC_re").style.display = "block";}
else
{ document.getElementById("RC_co").style.display = "none";
document.getElementById("RC_re").style.display = "none";
}

if (strRcReport == "Country")
{ document.getElementById("RC_OC").style.display = "block";}
else
{ document.getElementById("RC_OC").style.display = "none";}
}
else
{ document.getElementById("CO1").style.display = "none";
document.getElementById("CO2").style.display = "none";
document.getElementById("RC_re").style.display = "none";
document.getElementById("RC_co").style.display = "none";
document.getElementById("RC_OC").style.display = "none";
document.getElementById("RC_pe").style.display = "none";
document.getElementById("RC_view").style.display = "none";
document.getElementById("RC_down").style.display = "none";}
// <body bgcolor=#3399FF>
}

</script>

<center>
<h1><font face="Wide Latin">Fisheries Catch Statistic Reports</font></h1>

<body bgcolor="#3399FF">
<P>
<table datasrc='#data' CELLSPACING="12" BORDER="5" style="display:none" id="ResultsTable">
<thead>
<center><h1>Australian Monthly Report <br> Fish Catch Statistics</h1></center>
<tr><th>Time Period</th><th>Tones of Fish Species Caught</th></tr>
</thead>
<tbody> <tr>
<td><span datafld='Jan03'> </span></td>
<td><span datafld='East Coast'></span></td>
<td><span datafld='Great Barrier Reef'> </span></td>
<td><span datafld='Bass Strait'> </span></td>
<td><span datafld='etc'> </span></td>
</tbody>

</table>

<object ID=data classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param nAme="DataURL" value="Country.txt">
<param nAme="UseHeader" value="true">
</object>

<table CELLSPACING="12" BORDER="5" style = "display:block" id="ReportsTable">
<tr>
<td width="700"><input type="radio" id="report" name="report" value="SpeciesReport" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Fish Species Report</b>
<br>&nbsp;&nbsp;&nbsp;&nbsp;A view of catch data of a particular Fish Species. The data is divided by location.
<br>&nbsp;&nbsp;&nbsp;&nbsp;You specify the particular Fish Species that you want.
</font>
</td></tr>
<tr style = "display:none" id="Sp_sp">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;What Fish Species do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="Sp_sp" name="Sp_sp">
<option value="">Please Select
<option value="Tuna">Tuna
<option value="Dolphin">Dolphin
<option value="Nemo">Nemo
</select></td>
</tr>

<tr style = "display:none" id="Sp_ti">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;What period do you want the data broken down into?
&nbsp;&nbsp;&nbsp;</b>
<SELECT name="Sp_ti">
<option value="">Please Select
<option value="Mon">Monthly
<option value="Qua">Quarterly
<option value="Fin">Financial
<option value="Ann">Annual
</select></td>
</tr>
<tr style = "display:none" id="Sp_lo">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;What do you want the location broken down in?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="Sp_lo" name="800">
<option value="">Please Select
<option value="Aus">Australia
<option value="Ind">India
<option value="Chi">China
<option value="Jap">Japan
</select></td></tr>
<tr style = "display:none" id="Sp_view">
<td width="600"><center><input type="submit" name="Sp_view" value="View Report">
<input type="submit" name="Sp_down" value="Download Report"> </center>
<tr>
<td><input type="radio" id="report" name="report" value="CountryReport" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Country Report subdivided into regions</b>
<br>&nbsp;&nbsp;&nbsp;&nbsp;A view of catch data for a particular country.
<br>&nbsp;&nbsp;&nbsp;&nbsp;For this report you specify the country that you want to view the data for.
</font>
</td>
</tr>
<tr style = "display:none" id="Co_co">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;What Country do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;</b>
<SELECT id="Co_co" name="800">
<option value="">Please Select
<option value="Aus">Australia
<option value="Ind">India
<option value="Chi">China
<option value="Jap">Japan
</select></td>
</tr>
<tr style = "display:none" id="Co_ti">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;What period do you want the data broken down into?&nbsp;</b>
<SELECT name="Co_ti">
<option value="">Please Select
<option value="Mon">Monthly
<option value="Qua">Quarterly
<option value="Fin">Financial
<option value="Ann">Annual
</select></td>
</tr>
<tr style = "display:none" id="Co_lo">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;What do you want the location broken into?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;</b>
<SELECT id="Co_lo" name="800">
<option value="">Please Select
<option value="Co">Country
<option value="CoReg">Country/Region
</select></td>
<tr style = "display:none" id="Co_view">
<td><center><input type="submit" name="Co_view" value="View Report" onclick=show_report()> <input type="submit" name="Co_down" style = "display:none" id="Co_down" value="Download Report"> </center>
</td></tr>

<tr>
<td><input type="radio" id="report" name="report" value="RegionalReport" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Regional or Country Report divided by fish species</b>
<br>&nbsp;&nbsp;&nbsp;&nbsp;A view of catch data for a particular region or country.
<br>&nbsp;&nbsp;&nbsp;&nbsp;You specify the particular region or country that you want. The data is divided by fish species.
</font>
</td>
</tr>
<tr style = "display:none" id="RC_pe">
<td width="600"><b>What period do you want the data broken into?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="RC_pe" name="800">
<option value="">Please Select
<option value="Qua">Quarterly
<option value="Ann">Annual
</font>
</td></tr>
<tr style = "display:none" id="CO1">
<td>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="CO1" name="CO" value="RegionalCountry" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Regional and Country</b></td>
</tr>
<tr style = "display:none" id="RC_co">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What Country do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="RC_co" name="800">
<option value="">Please Select
<option value="Aus">Australia
<option value="Bog">Bogwanastan
</font>
</td></tr>
<tr style = "display:none" id="RC_re">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What Region do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="RC_re" name="800">
<option value="">Please Select
<option value="NSW">NSW
<option value="SA">SA
</font>
</td></tr>
<tr style = "display:none" id="CO2">
<td>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="CO2" name="CO" value="Country" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Country Only</b></td>
</tr>
<tr style = "display:none" id="RC_OC">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What Country do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="RC_OC" name="800">
<option value="">Please Select
<option value="Australia">Australia
<option value="Bog">Bogwanastan
</font>
</td></tr>
<tr style = "display:none" id="RC_view">
<td><center><input type="submit" name="RC_view" value="View Report"> <input type="submit" name="RC_down" style = "display:none" id="Co_down" value="Download Report"> </center>
</td></tr>

<tr>
<td><input type="radio" id="report" name="report" value="PeriodicalReport" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Periodical Catchment Report</b>
<br>&nbsp;&nbsp;&nbsp;&nbsp;A view of catch data for a time period. For example all the fish caught in a particular month or year.
<br>&nbsp;&nbsp;&nbsp;&nbsp;You specify which particular time period that you want.
</font>
</td>
</tr>
<tr style = "display:none" id="PE_lo">
<td width="600"><b>What do you want the location broken into?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="PE_lo" name="800">
<option value="">Please Select
<option value="CoRe">Country/Region
<option value="co">Country
</font>
</td></tr>
<tr style = "display:none" id="PE1">
<td>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="PE1" name="PE" value="PeriodMonth" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Monthly Time Period</b></td>
</tr>
<tr style = "display:none" id="PE_mm">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What Month do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="PE_mm" name="800">
<option value="">Please Select
<option value="Jan">January
<option value="Feb">February
</font>
</td></tr>
<tr style = "display:none" id="PE_my">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What Year do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="PE_my" name="800">
<option value="">Please Select
<option value="00">2000
<option value="01">2001
</font>
</td></tr>
<tr style = "display:none" id="PE2">
<td>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="PE2" name="PE" value="PeriodQuarter" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Quarterly</b></td>
</tr>
<tr style = "display:none" id="PE_qq">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What Quarter do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="PE_qq" name="800">
<option value="">Please Select
<option value="1">Jan-Mar
<option value="2">Mar-Jun
</font>
</td></tr>
<tr style = "display:none" id="PE_qy">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What Year do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="PE_qy" name="800">
<option value="">Please Select
<option value="01">2001
<option value="02">2002
</font>
</td></tr>
<tr style = "display:none" id="PE3">
<td>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="PE3" name="PE" value="PeriodFinancial" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Financial Year</b></td>
</tr>
<tr style = "display:none" id="PE_fy">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What Year do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="PE_fy" name="800">
<option value="">Please Select
<option value="1">July 2000 - June 2001
<option value="2">July 2001 - June 2002
</font>
</td></tr>
<tr style = "display:none" id="PE4">
<td>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="PE4" name="PE" value="PeriodCalender" onclick="toggle_fields()"></input>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Calender Year</b></td>
</tr>
<tr style = "display:none" id="PE_cy">
<td width="600"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What Year do you want?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
<SELECT id="PE_cy" name="800">
<option value="">Please Select
<option value="1">2001
<option value="2">2002
</font>
</td></tr>
<tr style = "display:none" id="PE_view">
<td><center><input type="submit" name="PE_view" value="View Report"> <input type="submit" name="PE_down" style = "display:none" id="Co_down" value="Download Report"> </center>
</td></tr>
</table>
<input type="submit" name="DummyButton" value="View Dummy Report" onclick=show_report()>
</form>

</body>
</html>
 

You would need to not deliver the ReportsTable code to the page to start with, but instead have it as a new page (for example, "ReportsTable.html". Then, use "window.open" to open this as new window:

Code:
window.open('ReportsTable.html', 'reportTable', '');

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Thanks for that Dan.

This system is supposed to work so that depending on which drop downs are selected it will open the report specific to those needs.
The main webpage needs to determine which text file to open and then that text file needs to be opened and read into a table in a new window.
Creating a webpage for every report will not work.
I can't think of a better way to open each of these reports in a new window.

When I try your code its not putting that table into the new page.
"window.open('ReportsTable.html', 'reportTable', '');"

Again thank you for all your help.
kybby
 

When I try your code its not putting that table into the new page.

The code I gave should not put any data into a page - it simply shows you how to open a new window containing a page that has already been created (or will br created dynamically using server-side scripting).

I'm not sure if I've misunderstood what you are asking, or whether you've misunderstood what I'm explaining... or maybe both.

You are writing a reporting solution, so presumably you have access to some kind of server-side scripting. Instead of delivering the data to the page above, you would deliver it to the page opened by the window.open method. This is why I included the window.open method - to show you how to open a new window. I assumed the rest would be obvious... so apologies if it was not.

Hope this helps,
Dan



[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top