| | |
Simple Java Script Question
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hi guys,
I am trying to hide 2 list boxes, then on selection changed show a new list box with JavaScript, i am very very new to web development in general, I am actually a software developer in the Pascal and C# language so this is all very new to me, please help with any ideas or code ?
This is what i have
I am aware of the fact that there is no Java Script in there yet because i have no idea how to go about this ...
Any help would be appreciated
Yours sincerely
Paul
I am trying to hide 2 list boxes, then on selection changed show a new list box with JavaScript, i am very very new to web development in general, I am actually a software developer in the Pascal and C# language so this is all very new to me, please help with any ideas or code ?
This is what i have
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%"> <tr> <td align="center" valign="middle" style="background: url('Image2.jpg') no-repeat fixed 50% top; height: 113px; color: #FFFFFF; font-family: Arial, Helvetica, sans-serif; font-style: normal; font-variant: normal; font-weight: bold; line-height: normal;" valign="top" class="style1"> NCS Quote System</td> </tr> <tr > <td style="width: 100%" valign="top" align="center" > <select title="Select a section :"> <?php //Selecting table Sections ***************************************************************** $Sections = mysql_query("SELECT * FROM sections", $connection); if (!$Sections) { die("Database query failed : " .mysql_error() ); } while ($RowSections = mysql_fetch_array($Sections)) { echo '<option value='.$RowSections['Description'].'>'.$RowSections['Description'].'</option>'; } echo '</select>'; ?> </td> </tr> <tr> <td style="width: 100%" valign="top" align="center"> <?php echo '<select>'; //Selecting table Categories ********************************************************* $Categories = mysql_query("SELECT * FROM categories, section_category_link WHERE categories.id = section_category_link.CategoryId", $connection); if (!$Categories) { die("Database query failed : " .mysql_error() ); } while ($RowCategories = mysql_fetch_array($Categories)) { echo '<option value='.$RowCategories['Description'].'>'.$RowCategories['Description'].'</option>'; } echo '</select>'; ?> </td> </tr> <tr> <td style="width: 20%" valign="top" align="center"> <?php echo '<select>'; //Selecting table Sub_Categories ****************************************************************** $Sub_Categories = mysql_query("SELECT * FROM subcategories, category_subcategory_link WHERE subcategories.id = category_subcategory_link.CategoryId ", $connection); if (!$Sub_Categories) { die("Database query failed : " .mysql_error() ); } while ($RowSubCategories = mysql_fetch_array($Sub_Categories)) { echo '<option value='.$RowSubCategories['Description'].'>'.$RowSubCategories['Description'].'</option>'; } echo '</select>'; ?> </td> </tr> <tr> <td style="width: 20%" valign="top" align="center"> <?php //Selecting table Sub_Categories ******************************************************************** $Items = mysql_query("SELECT * FROM items, subcategory_item_link WHERE items.Id = subcategory_item_link.ItemId", $connection); if (!$Items) { die("Database query failed : " .mysql_error() ); } while ($RowItems = mysql_fetch_array($Items)) { echo $RowItems["FullDescription"]. ", " .$RowItems["ShortDescription"] . ", " .$RowItems[""] . "<br />"; } ?> </td> </tr> </table>
I am aware of the fact that there is no Java Script in there yet because i have no idea how to go about this ...
Any help would be appreciated
Yours sincerely
Paul
Delphi & C# programmer deluxe...
Hope this example will help you on your way in learning javascript!
And Good day to you!
And Good day to you!
html Syntax (Toggle Plain Text)
<html> <head> <title><!--Sample--></title>
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> <!-- BEGIN HIDING /* ADD OPTION TO YOUR SELECTION LIST */ function addOpt() { /* You can also use the addOption function instead of this one! But since my browser doesnt support it! Then ill have to use the createElement method to add option on the list! */ var select = document.getElementsByTagName('select')[0]; var option = document.createElement('option'); for ( var x = 0; x < form1.list.options.length; x++ ) { option.text = 'Selection List ' + x; } select.appendChild(option); } <!-- SHOW AND HIDE YOUR COMBOboX! --> function hideMe( thisItem ) { div = document.getElementsByTagName('div'); div[thisItem].style.visibility = "hidden"; div['control'].innerText = 'Show Me!'; div['control'].onclick = function() { div['control'].innerText = "Hide Me!"; div['control'].onclick = "hideMe(\"sample\");"; div[thisItem].style.visibility = "visible"; } } // AND I'M DONE WITH HIDING --> </script>
html Syntax (Toggle Plain Text)
</head> <body> <div id="sample"> <form name="form1" action="#" onsubmit="return false;"> <select name="list" onchange="addOpt();"> <option>Hide Me!</option> <option>Add</option> </select> </form> </div> <div id="control" onclick="hideMe('sample');">Hide Me!</div> </body> </html>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
done
Help as an alias
I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
![]() |
Similar Threads
- Simple Shell Script Question.... [java related] (Shell Scripting)
- Servlet and JAVA Script + JSP (Java)
- How to Embed CheckList Box on HTML Page using Java Script (HTML and CSS)
- This Should be Easy for You Guys! (Linux Servers and Apache)
- Urgent Help Needed!!!! Plzzz (Java)
- Java practice questions (Java)
- creating a pop up window (HTML and CSS)
- Help with dynamic menu (HTML and CSS)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: need validation help
- Next Thread: How do i put data in html table with out data repetition
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser bug calendar captchaformproblem cart close codes column cookies css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 iframe index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps masterpage media menu microsoft mimic mp4 onmouseoutdivproblem onmouseover paypal pdf php player position post problem programming prototype redirect regex safari scale scriptlets scroll search security select software sql text textarea toggle unicode variables w3c website window windowofwords windowsxp





