uwictech Posted November 4, 2009 Share Posted November 4, 2009 Hi all, This is the first time I have posted on this forum, I was recomended from the PHP forum To cut a long story short here is the link to my post on the php forum. Hope someone can help! http://www.phpfreaks.com/forums/index.php?topic=275440.new;topicseen#new Jamie Quote Link to comment Share on other sites More sharing options...
xtopolis Posted November 5, 2009 Share Posted November 5, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.