Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Using HTML and PHP creating a drop down menu

HTML html5 Drop down menu help

  • Please log in to reply
6 replies to this topic

#1 Fenrir190

Fenrir190

    CC Newcomer

  • Member
  • PipPip
  • 16 posts
  • Programming Language:C, Java, C++
  • Learning:PHP, Python, JavaScript, Perl, Assembly, Bash

Posted 07 August 2012 - 07:12 AM

Since coming here to the site I've learned a lot about html, well a lot more than I did a month ago. But to my issue I was wondering if it was possible to create a drop down menu in html and in php simply display a table based on what's highlighted? If I'm not mistaken, I can't because php is server side and it must first have the information sent to it for processing before it can do anything. I hear javascript solves my problem just fine except there are two issues. One being my old professor, person who asked me to make the web page, only wants me to use php and html. Javascript is supposed to have a lot of security holes in it according to him and me never having used the language can't raise a proper argument. And two, like i said earlier, I have never used javascript. I would like to create the table dynamically based on the selected drop items but using only php and html it proves to be very complicated.
  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 07 August 2012 - 07:26 AM

HTML + CSS can create a dropdown menu, where clicking a link sends a form submission.

Regarding Javascript, almost EVERY website on the internet uses it. Google's main search page, Facebook, this site, etc. To be honest, you're more likely to have security issues with PHP on your server than with Javascript in your browser.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 A3MIRAL

A3MIRAL

    CC Newcomer

  • Member
  • PipPip
  • 16 posts
  • Location:USA
  • Programming Language:Java, C#, PHP, JavaScript, Bash
  • Learning:C, Objective-C, Python

Posted 07 August 2012 - 08:26 AM

HTML + CSS can create a dropdown menu, where clicking a link sends a form submission.

Regarding Javascript, almost EVERY website on the internet uses it. Google's main search page, Facebook, this site, etc. To be honest, you're more likely to have security issues with PHP on your server than with Javascript in your browser.


So true about the security!

For making the dropdown menu, check out this page:
http://www.w3schools.../tag_option.asp

For helping you connect the option tag with PHP (and many other input tags, all done similarly) check out this page:
http://www.tizag.com...les/formex.php/

Good luck!
  • 0

#4 Fenrir190

Fenrir190

    CC Newcomer

  • Member
  • PipPip
  • 16 posts
  • Programming Language:C, Java, C++
  • Learning:PHP, Python, JavaScript, Perl, Assembly, Bash

Posted 08 August 2012 - 07:19 AM

Thanks guys. I'm gonna redo the webpage and just explain to him that what he wanted just wasn't plausible. The main thing is getting the page up. I can basically just reuse the code I have now just add in the javascript as the I was just thinking of doing it wasn't gonna be plausible knowing both myself and the timeline I have to work on this.
  • 0

#5 Fenrir190

Fenrir190

    CC Newcomer

  • Member
  • PipPip
  • 16 posts
  • Programming Language:C, Java, C++
  • Learning:PHP, Python, JavaScript, Perl, Assembly, Bash

Posted 08 August 2012 - 11:22 AM

Ok so I've managed to get what I needed done with php and html by simply
function display_dropMenu($option)
{
  //switch($option)
  //{
   //case: 4
    //$sq = "SELECT * FROM STUDENT_OUT ORDER BY id ASC;";
  //} //ends switch(option)
  $sq = "SELECT * FROM STUDENT_OUT ORDER BY id ASC;";
  $sr = mysql_query($sq);

  $_SESSION['num_rows'] = $num_rows = mysql_num_rows($sr);
  $num_fields = mysql_num_fields($sr);

  //printf("Number rows %s Number fields %s", $num_rows, $num_fields);

  echo "<form method=\"POST\" action=\"include/\">";
  echo "<select name=\"dValue\">";
  echo "<option value=\"\"> </option>";

  for($i = 0; $i < $num_rows; $i++)
  {
   $row = mysql_fetch_array($sr, MYSQL_NUM);

   echo "<option value=".$row[0].">".$row[1]."</option>";
  }
  echo "</select>";
  echo "<input type= \"submit\" value=\"Display\">";
  echo "</form>";
  display_tbl(4); // <== Apparently I can just call this if the form data doesn't get sent anywhere
} //ends function displayDropmenu

While it does what I need it to do I'm not exactly happy with the look and feel of the site. J&#097;v&#097;script would be a welcomed addition to the site but it's beyond my knowledge(right now). The little time I have left on my contract won't allow me to both learn JS and add it to the site but this has convinced me to get my skills up in that language. Thanks again guys.
  • 0

#6 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 08 August 2012 - 10:27 PM

Where exactly lies the risk in using Javascript as web developer?
  • 0

#7 chrisnl

chrisnl

    CC Lurker

  • New Member
  • Pip
  • 6 posts
  • Location:127.0.0.1
  • Programming Language:PHP
  • Learning:Java, Python, JavaScript, Delphi/Object Pascal, Pascal

Posted 29 August 2012 - 08:40 AM

you didn't read it correctly, javascript is better secured than PHP
  • 0





Also tagged with one or more of these keywords: HTML, html5, Drop down, menu, help

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download