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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.