Jump to content

Drop down menu + variable


uwictech

Recommended Posts

I read the thread several times and I'm still confused about what you want it to do.  Going by your first post "select site and then show the ip address", you could do that in one database call as such:

 

(Note, this code isn't pretty, but should give you an idea of functional possibilities)

<?php
      require("confwifi.php");

$ip_form = $_POST['ip'];

$extract = mysql_query ("SELECT id,site,ip FROM site");
$numrows = mysql_num_rows ($extract);

$options = '';
  while(list($id, $site, $ip) = mysql_fetch_assoc($extract))
  { 
    $options .= "<option value='$id' ip='$ip'>$site</option>";
  }

?>

<html>
<head>
<script type="text/javascript">
function showSelected(trgt, val)
{
  var x = document.getElementById(trgt);
  x.innerHTML = val;
}//show selected
</script>
</head>
<body>

<p>Select CAMPUS: <select name="ip" onchange="showSelected('selectedResult', this.options[this.selectedIndex].getAttribute('ip'));">
  <?php echo $options; ?>
</select>
</p>

<div id='selectedResult'></div>
</body>
</html>

 

What I did was add a custom attribute "ip" to the option tag for each site and read and display the data using javascript.  I assume that is similar to what you wanted to do seeing as how you had a javascript function in place (though no code was provided for it)

 

As for your other posts in the thread about "doing something with the variable later", you'll have to explain further as I did not follow what you were trying to explain.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.