Hi, what's up??? i think right now in a simple solution. there are many more solutions, i would like with ajax, but first the first
<?php
// @jacsdev
// define your data connection
$host = '';
$user = '';
$pwd = '';
$db = mysql_connect($host, $user, $pwd) or die("Sorry, it's not possible");
mysql_select_db($dbName);
if(isset($_GET['server']) && !empty($_GET['server']))
{
$server = $_GET['server'];
// now, as you see, we have in $server the value selected in dropdown list
// so, we can do our query now:
// this query is an example, you can modify
$cn_server = mysql_query("select * from other_table_with_data where server_name='".$server."'");
//..
}
?>
<form action="" onsubmit="return validateForm();">
Choose a Server:
<select name="myServers" id="myServers" onchange="selectMyServer(this.value);">
<option value="-">-</option>
<?php
$cn = mysql_query("select server_name, server_ip, server_type from server_list_table");
while($rs = mysql_fetch_array($cn))
{
?>
<option value="<?php echo $rs['server_name']; ?>"><?php echo $rs['server_name']; ?></option>
<?php
}
?>
</select>
<br />
<br />
<input type="submit" value="Send Data" />
</form>
<script language="javascript" type="text/javascript">
function selectMyServer(server)
{
if(server != '-')
{
// i get current page
var myCurrentPage = location.href;
// now, i setting my current page. we must add selected server in new url
location.href = myCurrentPage +'?server=' + server; // redirecting to curret page
}
}
function validateForm()
{
if(document.getElementById('myServer').value !='-')
{
alert('please, choose a server');
return false;
}
}
</script>
when you choose a server in dropdown, the onChange event is launched. this event invoke to selectMyServer function, passing selected server as argument... so, the function redirect to same page with the name of selected server and then you can do a query with this value..
i hope help you friend
@jacsdev