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')"/>
send an html variable to php file without submit button
Moderator: General Moderators
Re: send an html variable to php file without submit button
you can use javascript to get the value of the dropdown...by giving id to the select box ie the drop down...and then when you click the button call a javascript function...inside the javascript function...get the value of the drop down by passing the id..you can see some javascript manual to see how to get value using the id...and then you can pass it to php... by sending to the php page like window.location='filename?dropdownvalue='+selectedvaue; some thing like that...
Re: send an html variable to php file without submit button
Thank you Anantha, I was hoping to find a solution without using javascript, it seems it si the only solution
I'll start working on it, and post the solution later on
I'll start working on it, and post the solution later on
[RESOLVED] send html variable to php file without submit but
here is the solution:
Add this first:
<script language="javascript" type="text/javascript">
function returnBTAvalue(){
d= document.getElementById("BTAfilter").value;
return d;
}
function openSNMPwindow() {
window.open('Queries/snmp_mon_bandwidth_output-v1.php?BTAfilter='+returnBTAvalue(),'SNMP_Configuration','width=1200,height=500,resizable=yes,scrollbars=yes');
}
</script>
Modify the select tag: (attention id and no more name)
echo "<select id=BTAfilter onchange='returnBTAvalue()'>\n\t<option value=ALL>Select BTA\n";
Modify the button tag:
<input type="button" name="bw_monitoring" style="height: 25px; width:200px" value="SNMP Bandwidth Monitoring" onClick="openSNMPwindow()"/>
Add this first:
<script language="javascript" type="text/javascript">
function returnBTAvalue(){
d= document.getElementById("BTAfilter").value;
return d;
}
function openSNMPwindow() {
window.open('Queries/snmp_mon_bandwidth_output-v1.php?BTAfilter='+returnBTAvalue(),'SNMP_Configuration','width=1200,height=500,resizable=yes,scrollbars=yes');
}
</script>
Modify the select tag: (attention id and no more name)
echo "<select id=BTAfilter onchange='returnBTAvalue()'>\n\t<option value=ALL>Select BTA\n";
Modify the button tag:
<input type="button" name="bw_monitoring" style="height: 25px; width:200px" value="SNMP Bandwidth Monitoring" onClick="openSNMPwindow()"/>