send an html variable to php file without submit button
Posted: Thu Jan 20, 2011 11:45 am
Hi,
i have an html page, in which I've created a form with many buttons (inputs). Some of these buttons has a type of submit, and thus open a new page when clicking on taking in consideration the variables entered.
In this same form, i want to create a button, that opens a new window when we click on it, and executes a php scripts taking in consideration a variable selected from a drop down list in the home html page.
the problem is that i don't know how to pass the selected variable from the drop down list to the php script.
N.B. it works with the submit button
My question is, how do i send it from the html file, and how do i get it in the php script
here is part of the code:
<form id="form1" name="form1" method="post" action="sig_analysis.php">
<b>Global Search Filters</b>
<p>
<img src="./images/black_dot" alt="black_dot"></img> Date and Time Filters
</p>
<p>
<input id="filterstart_cal" type="text" name="filterstart" size="20" maxlength="19" value="<?php echo $_SESSION['filterstart'] ?>"/>
<a title = "Calendar" href="javascript:openCalendar('<?php echo $token ?>','insertForm','filterstart','datetime')">
<img class="calendar" src="./images/b_calendar.png" alt="Calendar"/></a> Start of period (YYYY-MM-DD HH:MM:SS)
</p>
<p>
<input type="text" name="filterend" size="20" maxlength="19" value="<?php echo $_SESSION['filterend'] ?>"/>
<a title = "Calendar" href="javascript:openCalendar('<?php echo $token ?>','insertForm','filterend','datetime')">
<img class="calendar" src="./images/b_calendar.png" alt="Calendar"/></a> End of Period (YYYY-MM-DD HH:MM:SS)
</p>
<p>
<img src="./images/black_dot" alt="black_dot"></img> BTA ID Filter
<img src="./images/black_dot" alt="black_dot"></img> BTA's Tunnel Number Filter
</p>
<p>
<?php
$database="csodb";
$host='127.0.0.1:6060';
$user_base='root';
$passwd_base='private';
$link = mysql_connect($host,$user_base,$passwd_base);
mysql_select_db($database) or die ("Error: ". mysql_error(). " with query ". $database);
echo "<select name=BTAfilter>\n\t<option value=ALL>Select BTA\n";
$cxg_query = "SELECT DISTINCT cxid FROM csodb.cx_archive WHERE typedevice = 'CXG'";
$cxg_query_result = mysql_query($cxg_query);
while ($row = mysql_fetch_object($cxg_query_result)){
echo "\t<option value=".$row->cxid .">".stripslashes($row->cxid)."</option>\n" ;
}
echo "</select>";
mysql_close($link);
?>
<input type="submit" name="sig_counters_loops" style="height: 25px; width:200px" value="Loops Found" />
<input type="button" name="bw_monitoring" style="height: 25px; width:200px" value="SNMP Bandwidth Monitoring" onClick="window.open('Queries/snmp_mon_bandwidth_output-v1.php?BTAfilter=?????????','SNMP_Configuration','width=1200,height=500,resizable=yes,scrollbars=yes')"/>
i have an html page, in which I've created a form with many buttons (inputs). Some of these buttons has a type of submit, and thus open a new page when clicking on taking in consideration the variables entered.
In this same form, i want to create a button, that opens a new window when we click on it, and executes a php scripts taking in consideration a variable selected from a drop down list in the home html page.
the problem is that i don't know how to pass the selected variable from the drop down list to the php script.
N.B. it works with the submit button
My question is, how do i send it from the html file, and how do i get it in the php script
here is part of the code:
<form id="form1" name="form1" method="post" action="sig_analysis.php">
<b>Global Search Filters</b>
<p>
<img src="./images/black_dot" alt="black_dot"></img> Date and Time Filters
</p>
<p>
<input id="filterstart_cal" type="text" name="filterstart" size="20" maxlength="19" value="<?php echo $_SESSION['filterstart'] ?>"/>
<a title = "Calendar" href="javascript:openCalendar('<?php echo $token ?>','insertForm','filterstart','datetime')">
<img class="calendar" src="./images/b_calendar.png" alt="Calendar"/></a> Start of period (YYYY-MM-DD HH:MM:SS)
</p>
<p>
<input type="text" name="filterend" size="20" maxlength="19" value="<?php echo $_SESSION['filterend'] ?>"/>
<a title = "Calendar" href="javascript:openCalendar('<?php echo $token ?>','insertForm','filterend','datetime')">
<img class="calendar" src="./images/b_calendar.png" alt="Calendar"/></a> End of Period (YYYY-MM-DD HH:MM:SS)
</p>
<p>
<img src="./images/black_dot" alt="black_dot"></img> BTA ID Filter
<img src="./images/black_dot" alt="black_dot"></img> BTA's Tunnel Number Filter
</p>
<p>
<?php
$database="csodb";
$host='127.0.0.1:6060';
$user_base='root';
$passwd_base='private';
$link = mysql_connect($host,$user_base,$passwd_base);
mysql_select_db($database) or die ("Error: ". mysql_error(). " with query ". $database);
echo "<select name=BTAfilter>\n\t<option value=ALL>Select BTA\n";
$cxg_query = "SELECT DISTINCT cxid FROM csodb.cx_archive WHERE typedevice = 'CXG'";
$cxg_query_result = mysql_query($cxg_query);
while ($row = mysql_fetch_object($cxg_query_result)){
echo "\t<option value=".$row->cxid .">".stripslashes($row->cxid)."</option>\n" ;
}
echo "</select>";
mysql_close($link);
?>
<input type="submit" name="sig_counters_loops" style="height: 25px; width:200px" value="Loops Found" />
<input type="button" name="bw_monitoring" style="height: 25px; width:200px" value="SNMP Bandwidth Monitoring" onClick="window.open('Queries/snmp_mon_bandwidth_output-v1.php?BTAfilter=?????????','SNMP_Configuration','width=1200,height=500,resizable=yes,scrollbars=yes')"/>