HTML - Selected In Drop Down
Hi guys, i have a drop down code below
Quote: <select class="input" name="mod[cpu]"> <option value=""> </option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> the output are like this Quote: $html .= ($content[cpu] ? '<div class="' . $this->switch_bg() . '"><strong>CPU:</strong> ' . @htmlspecialchars($content[cpu]) . '</div>' : ''); i want after the drop down choosed by user, it will add SELECTED next time they opening the drop down again i am still dont know how to put the SELECTED there, please help what is the code to add SELECTED, i only have variable mod[cpu] and $content[cpu] i already tried in bold below, but still not working Quote: <select class="input" name="mod[cpu]" selected="$content[cpu]"> <option value=""> </option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> please share your knowledge Similar TutorialsI am trying drop-down box with pre-selected value.Here is the example i am using, <html> <body> <p><b>Drop down box with pre-selected value</b></p> <form> <select name="cars"> <option value="Volvo">Volvo</option> <option value="Saab">Saab</option> <option vaue="Mercedes" selected="selected">Mercedes</option> <option value="BMW">BMW</option> </select> </form> </body> </html> when i load the page mercedes appears as the selected value.but if i change the value to something else and then click refresh button value doesnot change back to mercedes again.It still shows previously selected value.Why is this happening? Hello - I am using a Selection/Drop Down box in my form. I use a database to populate the drop down box, which is working fine. A sample bit of the result would look like this: <option value="1">California> <option value="2">Nevada> etc. etc. This appears to be working just fine - the drop down box is fully populating and displaying as expected. My form "action" needs to "know" which option was selected, so that it can send the ID value (1,2,3,etc) to the next page and continue executing accordingly. The only area where I am having trouble is in this line: <form method="post" action="details.php?id=[[WhatGoesHere??]] ">... (note that "details.php" is a valid file, works great if I hard code this line with a valid ID #) I am totally unclear as to what code should go after 'id=' This is easy, right? I just don't know the syntax/code. Do I have to go to Javascript to get the <option value> of the selected item? Doesn't the form have a way to give me this value? I am ok with PHP, not as good with Javascript, if I have to go there to do this. thanks, Wtc Hi all. I have a page that the select box is not selecting the option when selected is put in there. Here is the code. Any help you have is appreciated =) Thank you =) Light and Love and Healing to you, -Patrick Arden McNally Code: <html> <head> <title>DULUTH Music Scene</title> <link rel="stylesheet" type="text/css" href="music_scene.css"> </head> <body > <div class="wrapper"> <table width="100%"> <tr><td colspan="2"> <table width="100%" border="1"> <tr width="100%" align="center" valign="top"> <td><a href="index.php">Home</a></td><td><a href="calendar.php">Calendar</a></td><td><a href="featured.php">Featured Shows</a></td> <td><a href="view.php?mode=3">Venues</a></td><td><a href="view.php?mode=2">Local Artists</a></td><td> <a href="classifieds.php?type=1">Instruments</a><br> <a href="classifieds.php?type=2">Lessons</a><br> <a href="classifieds.php?type=3">Repairs</a><br> </td> <td><a href="email.php">Contact<br><a href="about.php">About Us</a><br><a href="user_reg.php">Join</a></td></tr> </table> </td></tr> <tr> <td><h2> DULUTH<br>Music Scene</h2> </td><td align="right"> You are logged in (admin) <a href="logout.php">logout</a><br> <a href="home.php">My Profile</a> | <a href="admin.php">MusicScene Admin </a></td></tr> <tr><td colspan="2"> <hr> <h2>Edit Featured Show</h2> <form action="admin.php?mode=edit_featured" method="post" name="form1" enctype="multipart/form-data"> <input type="hidden" name="mode" value="edit_featured"> <input type="hidden" name="id" value="9"> <input type="hidden" name="regionID" value="1"> Shows: <select name="showID"><option value="27" selected>2009-04-25 - The Rez <br>The Big Wu - The Orpheum Duluth - NorShor Theatre 1st Floor</option><option value="33" >2009-06-25 - The Infinite Flow <br>The Lovers - Blue Crab</option><option value="8" >2009-07-10 - The Infinite Flow <br> Johnny Reeferseed & the High Rollers<br> Harmonic Order<br> Cirrus Minor<br> The Rez<br> Dead L - Mellow Meddle Music Festival</option><option value="10" >2009-07-10 - The Rez <br>The Infinite Flow<br> Harmonic Order - Mellow Meddle Music Festival</option><option value="15" >2009-07-10 - The Infinite Flow <br>The Rez - Mellow Meddle Music Festival</option><option value="29" >2010-10-20 - The Hobo Newphews of Uncle Frank <br>JnvsVwNotS - The Rex</option></select><br> Description: <textarea name="description" cols="80" rows="10">The Rez and The Histronic will be opening for The Big Wu on Saturday April 25th at the Historic NorShor Theatre in Duluth (Now Called The Orpheum Duluth).</textarea><br> User: <select name="userID"> <option value="16" >Jamie Ness</option> <option value="17" >Jim Hall</option> <option value="18" >Marc Gartman</option> <option value="19" >Too Many Banjos</option> <option value="20" >Acceleratii</option> <option value="21" >Root City Band</option> <option value="22" >The Tisdales</option> <option value="23" >Equal Xchange</option> <option value="24" >Charlie Parr</option> <option value="25" >Uprising</option> <option value="26" >The Fractals</option> <option value="27" >Lonesome Dan Kase</option> <option value="28" >Ian Alexy</option> <option value="29" >The Hobo Newphews of Uncle Frank</option> <option value="30" >The Hobo Newphews of Uncle Frank</option> <option value="45" >Thirsty Pagan Brewing</option> <option value="46" >Lakeview Castle</option> <option value="48" >The Orpheum Duluth - NorShor Theatre 1st Floor</option> <option value="49" >The Rex</option> <option value="60" >Sir Benedict's Tavern on the Lake</option> <option value="61" >Pizza Luce</option> <option value="62" >Blue Crab</option> <option value="63" >Fitger's Brewhouse</option> <option value="51" >#dennick[IRIFIFZFZIII]</option> <option value="52" >2</option> <option value="12" >Music Scene Admin</option> <option value="47" >Angelic Ascension</option> <option value="13" >The Infinite Flow</option> <option value="58" >infoffwrofE</option> <option value="59" >itedgeGootorm</option> <option value="55" >Josh Brown</option> <option value="56" >pp</option> <option value="57" >pp</option> <option value="42" >Patrick</option> <option value="43" >Patrick</option> <option value="44" >Patrick Arden McNally</option> <option value="8" >Patrick Arden McNally</option> <option value="9" >Patrick Arden McNally</option> <option value="15" >Teague Alexy</option> <option value="14" >The Beat Coffee House</option> <option value="31" selected>The Rez</option> <option value="2" >Tim and Pat</option> <option value="6" >Twins Bar</option> <option value="50" >xpokvmihdsz</option> </select><br> Date Start: <select name="date_start_month"><option value="01" >Jan</option><option value="02" >Feb</option><option value="03" >Mar</option><option value="04" selected>Apr</option><option value="05" >May</option><option value="06" >Jun</option><option value="07" >Jul</option><option value="08" >Aug</option><option value="09" >Sep</option><option value="10" >Oct</option><option value="11" >Nov</option><option value="12" >Dec</option></select><select name="date_start_day"> <option value="01" >01</option><option value="02" >02</option><option value="03" >03</option><option value="04" >04</option><option value="05" >05</option><option value="06" >06</option><option value="07" >07</option><option value="08" >08</option><option value="09" >09</option><option value="10" >10</option><option value="11" >11</option><option value="12" >12</option><option value="13" >13</option><option value="14" >14</option><option value="15" >15</option><option value="16" >16</option><option value="17" >17</option><option value="18" >18</option><option value="19" >19</option><option value="20" >20</option><option value="21" selected>21</option><option value="22" >22</option><option value="23" >23</option><option value="24" >24</option><option value="25" >25</option><option value="26" >26</option><option value="27" >27</option><option value="28" >28</option><option value="29" >29</option><option value="30" >30</option><option value="31" >31</option></select> <select name="date_start_year"><option value="2009" selected>2009</option><option value="2010" >2010</option><option value="2011" >2011</option><option value="2012" >2012</option><option value="2013" >2013</option></select><br> Date End: <select name="date_end_month"><option value="01" >Jan</option><option value="02" >Feb</option><option value="03" >Mar</option><option value="04" selected>Apr</option><option value="05" >May</option><option value="06" >Jun</option><option value="07" >Jul</option><option value="08" >Aug</option><option value="09" >Sep</option><option value="10" >Oct</option><option value="11" >Nov</option><option value="12" >Dec</option></select><select name="date_end_day"> <option value="01" >01</option><option value="02" >02</option><option value="03" >03</option><option value="04" >04</option><option value="05" >05</option><option value="06" >06</option><option value="07" >07</option><option value="08" >08</option><option value="09" >09</option><option value="10" >10</option><option value="11" >11</option><option value="12" >12</option><option value="13" >13</option><option value="14" >14</option><option value="15" >15</option><option value="16" >16</option><option value="17" >17</option><option value="18" >18</option><option value="19" >19</option><option value="20" >20</option><option value="21" >21</option><option value="22" >22</option><option value="23" >23</option><option value="24" >24</option><option value="25" >25</option><option value="26" selected>26</option><option value="27" >27</option><option value="28" >28</option><option value="29" >29</option><option value="30" >30</option><option value="31" >31</option></select> <select name="date_end_year"><option value="2009" selected>2009</option><option value="2010" >2010</option><option value="2011" >2011</option><option value="2012" >2012</option><option value="2013" >2013</option></select><br> Paid: <input type="checkbox" name="paid" checked> Payment ID: <input type="text" name="payment_id" value=""><br> Active: <input type="checkbox" name="active" checked><br> Type: Front Page <input type="radio" name="featured_type" value="1" checked> | Featured Shows Page <input type="radio" name="featured_type" value="2" ><br> Featured photo: <input type="file" name="featured_photo"><br> <input type="hidden" name="featured_photo_old" value=""> <input type="submit" name="submit" value="Submit"> </form> <br><hr><br><br><br> <a href="admin.php?mode=featured">Add/Edit Featured Shows</a> | <a href="admin.php?mode=banners">Add/Edit Banners</a> | <a href="admin.php?mode=classifieds">Add/Edit Classifieds</a> | <a href="admin.php?mode=report">View Site Reports</a> <tr><td colspan="2" align="center"> <br><br> </td></tr> </table> </div><div class="push"> <div class="footer"><a href="about.php">About us</a> | <a href="email.php">Contact Us</a><br> <div style="font-size: 12px;">Website Design by <A href="http://www.thedesignedge.com/">The Design Edge</a> - ©2009 Music-Scene.org</div></div> </body></html> I have a drop down menu that changes the page when one of the options is selected. When I select an option, I want that option to become the selected option. Here is some example code. <select class="select" name="Gender" onchange="submit()"> <option value="">Gender</option> <option value="0">Female</option> <option value="1">Male</option> </select> If I select "Female" I want that option to be selected when the page reloads. Now the menu resets to "Gender" every time the page reloads. Thanks I have a drop down box with a few items that can be selected. <select name="id_products" id="id_products"> <option value="CHOOSE ONE">CHOOSE ONE...</option> <option value="Bundle 1">Bundle #1 ($5795)</option> <option value="Bundle 2">Bundle #2 ($5495)</option> <option value="Bundle 3">Bundle #3 ($5295)</option> </select> When an item is selected and the Submit button is clicked, the form POSTS to FormMail.php which sends me an email with the value of "id_products". What I want to do is to expand on what the "Bundles" are before sending by email. For example, if "Bundle 2" is selected, then "id_products" equals "Bundle 2". I want to check what "id_products" is before sending this off to the FormMail.php and change it to something more descriptive, like: If id_products = "Bundle 2" then id_products = "Mustang $495 Pinto $23 Chevy $1200" So instead of receiving for id_products "Bundle 2" by email, I get... Mustang $495 Pinto $23 Chevy $1200 ... instead. Can this be done? Thanks. Webbiz Hi there, I am using dreamweaver to make this website and I have got a little problem. I have got this template which has a top nav bar, and if it is selected it has a class="current" for CSS. I am using it in a template so when one updates they all do. This is where the problem occurs. I cannot set each one to current on the nav bar. I could make the nav bar and editable region, however I dont want to, as then if I update it, it wont up date any of the others. Is there a way to do a sort of IF statment saying if the url equals www.mydomain.com/aboutus.html class equals current? Thanks. Josh So I have code that opens a file input dialog box where a person can pick an image to upload. Once an image is selected, I want the image to appear on the web page. The problem is, I dont know how to show the image, because the source is unknown. After the user selects the image from the dialog box, is there any way to show it? <input type="file" name="diagram" size="40"> <img src=( what do I put here to show the image that was selected ) align="right" style="padding-right:10px" alt="dataFlowDiagram" /> Hi all, I have various anchors on my web-pages that do not actually load new pages..so they look like: Code: <a href="javascript:return false;" onclick="doSomething();">foobar</a> problem is, when a user clicks the anchor the anchor becomes 'selected' showing a box around the anchor..which I do not want..I'm no HTML/CSS guru and have no idea to fix it so that when anchor is 'selected' it does not 'show the box around it'..any tips on what I can do? (I suppose I could try and change it to use spans instead of anchors, but..then the 'mouse cursor' does not change properly when users hover over the anchor). ps. the website url: www.borrownet.com every menu link has this issue. Hello, I am facing a weird problem in IE which is not happening with other browsers. Open the following website: http://www.clinicasdefertilidadenlima.pe/ You will see 3 combo boxes on this page displaying "Lima". Click on any combo and select any other value like Lima or Arequipa. Page will refresh but now combo will not show selected value which should always be "Lima" (I have hard coded it) If you take a look at the HTML source then it's a simple combo box and I have even defined selected="selected" for "Lima" value but in IE it only displays selected value when you open home page. After that it doesn't show value when you select value from combo box. I am using IE9. Here is the combo box I am talking about: HTML Code: <select id="city_id" name="city_id" class="f2_city" onchange="redirect(this.form)"> <option value="" selected="selected">LIMA</option> <option value="LIMA">LIMA</option> <option value="Arequipa">Arequipa</option> </select> Thanks i recently learned html, still a n00b though, lol i made a layout, which im proud of but i wanna know how to make a layout changer, which i can pput as a topic and have links, when ppl click them, the layout changes, and u can always chnge it bak to the original or something else mind helping me out? I'm having trouble getting firefox to preselect an option using selected in the option tag. It's in a php app, but I've made a simple test in just html and it displays the same behaviour. Does the following code work right for anyone else with firefox 3? Code: <html> <head> <meta http-equiv="Pragma" content="no-cache" /> </head> <body> <form> <p>display email? <select name="display_email" size="2"> <option value="no">no</option> <option selected="selected" value="yes">yes</option> </select> </form> </body> </html> I've also tried just 'selected', and selected="yes" but to no avail. Thanks Hello everybody, maybe someone can help me with a problem on my site. There is a form on the page where the user can select images from a dropdown list, it looks like this: Code: <FORM NAME="form"> <SELECT NAME="selbox" SIZE="1" ONCHANGE="imgchange()"> <OPTION VALUE="cards/gifs/deck1">Essential</OPTION> <OPTION VALUE="cards/gifs/fool">0</OPTION> <OPTION VALUE="cards/gifs/magician">I</OPTION> <OPTION VALUE="cards/gifs/priestress">II</OPTION> <OPTION VALUE="cards/gifs/empress">III</OPTION> </SELECT> </FORM> </TD> <TD VALIGN="TOP" ALIGN="CENTER"><BR> <FORM NAME="frm"> <INPUT TYPE="text" SIZE="18" NAME="indate"><P><INPUT TYPE="button" VALUE="show me" ONCLICK="getcard()"></P> </FORM> Now I would like to put a link on each image when it is shown on the page, so that the user can click on it and get the 'explanation window'. How should I write the links when the url should load in a popup window? The link for one image would look like this: Code: <A HREF='javascript:cards("cards/fool.html")' ONFOCUS="this.blur();">xxx</A> Right now I do not even manage to open a link in the same window, let alone in a pop up.. Any help would be greatly appreciated, thanks for reading! Yatkha How do I get the selected item from a select option list? I dont need the value I need the text associated with the value. I can get the value with (in vbscript): strValue = .mylist.value Have searched google exhaustively to see how to do this simple thing but have found nothing. Thanks. Hi, I am working on adding non java-script buttons on my website using CSS style sheets. I used a technique given at http://builder.com.com/5100-6371-5323375-2.html. I modified the colors a little but it is basically using technique 2 at this link. Everything works well with the exception of one issue. In Internet Explorer, when I press a link and then use the back button on the browser to return to the previous page, the link for the previous page is still selected and the button appears to still be "pressed". You can see this by going to http://www.apexmoves.com with internet explorer, clicking one of the buttons on the left side of the site, and then using the browser's back button. You will see that the link that was clicked is still selected and this button appears to be stuck in the down position. If you click anywhere else on the screen, the button is released. This is because the link for the pressed button is has the status of active. Does anyone have any ideas on how to solve this. Is that a way to make the status of this link "visited"? Any Ideas would be greatly appreciated. Thanks Brad Everything is working expect the list such as Happy Birthday Card etc should display image on another place when selected an item. Look at my java code (red). It is not working. <head> <style> body { margin: 20px; } select { float: left; } optgroup { text-indent: 5px; } option { padding: 0 10px 0 15px; } table { border-spacing: 20px 2px; } th { text-align: left; text-decoration: underline; } td:last-child { text-align: right; } </style> <script> window.onload = function() { document.getElementById("dlist1").onchange = function() { var option = this.options[this.selectedIndex]; document.getElementById("price_card").innerHTML = option.getAttribute("data-card") ? option.getAttribute("data-card") : ""; document.getElementById("price_memo").innerHTML = option.getAttribute("data-memo") ? option.getAttribute("data-memo") : ""; document.getElementById("price_tags1").innerHTML = option.getAttribute("data-tags1") ? option.getAttribute("data-tags1") : ""; document.getElementById("price_tags4").innerHTML = option.getAttribute("data-tags4") ? option.getAttribute("data-tags4") : ""; document.getElementById("price_key").innerHTML = option.getAttribute("data-key") ? option.getAttribute("data-key") : ""; document.getElementById("price_fridge").innerHTML = option.getAttribute("data-fridge") ? option.getAttribute("data-fridge") : ""; } } </script> <script type="text/javascript"> function swapImage1() { var image = document.getElementById("imageToSwap1"); var dropd = document.getElementById("dlist1"); image.src = dropd.value; }; </script> </head> <body> <select name="ORDER1" size="12" multiple="multiple" id="dlist1" onchange="swapImage1() "> <optgroup label="Sow Seeds of Love"> <option value="None">None</option> <option data-card="32.00" data-memo="62.00" data-tags1="8.50" data-tags4="1.80" data-key="30.00" data-fridge="40.00" value="Images/photo1.jpg">Happy Birthday Card</option> <option data-card="35.00" data-memo="65.00" data-tags1="9.50" data-tags4="1.80" data-key="20.00" data-fridge="40.00" value="Images/photo2.jpg">Get well soon Card</option> <option data-card="1.00" data-memo="2.00" data-tags1="3.00" data-tags4="4.00" data-key="5.00" data-fridge="6.00" value="Images/photo3.jpg">Wedding Card</option> <option data-card="6.00" data-memo="5.00" data-tags1="4.00" data-tags4="3.00" data-key="2.00" data-fridge="1.00" value="Images/photo4.jpg">New Baby Card</option> <option data-card="21.00" data-memo="22.00" data-tags1="23.00" data-tags4="24.00" data-key="25.00" data-fridge="26.00" value="Images/photo1.jpg">Thank you Card</option> </optgroup> </select> <table width="700"> <tr> <td> <img class="ImageToSwap" id="imageToSwap1" src="Images/Card.jpg" width="147" height="207" /> </td> </tr> </table> <table> <tr> <th>Description</th> <th>Price</th> </tr> <tr> <td><label><input type="radio" name="medium" value="card" /> Card A6 (blank)</label></td> <td id="price_card"></td> </tr> <tr> <td><label><input type="radio" name="medium" value="memo" /> Memo Book A6</label></td> <td id="price_memo"></td> </tr> <tr> <td><label><input type="radio" name="medium" value="tags4" /> Gift Tags (4 designs per packet)</label></td> <td id="price_tags4"></td> </tr> <tr> <td><label><input type="radio" name="medium" value="tags1" /> Gift Tags - Single - Assorted</label></td> <td id="price_tags1"></td> </tr> <tr> <td><label><input type="radio" name="medium" value="key" /> Key Rings Perspex</label></td> <td id="price_key"></td> </tr> <tr> <td><label><input type="radio" name="medium" value="fridge" /> Fridge Art</label></td> <td id="price_fridge"></td> </tr> </table> </body> </html> Hello everybody, I have a problem. I have a listbox in the form and a submit button. the listbox has multiple selection enabled. Im able to select multiple values in the listbox. now when i submit this form, i want all the values selected, how can i do that. regards Mohsin iqbal So I have a radio group within a form. Specifically, here is my code: HTML Code: <table> <tr> <td><label> <input type="radio" name="question_1" value="Average" id="question_1_0" /> Average</label></td> <td><label> <input type="radio" name="question_1" value="Large" id="question_1_1" /> Large</label></td> <td><label> <input type="radio" name="question_1" value="Gigantic" id="question_1_2" /> Gigantic!</label></td> <td><label> <input type="radio" name="question_1" value="Getting_larger" id="question_1_3" /> It's Getting Larger...</label></td> </tr> </table> So I need to set an initially selected on this radio group. How do I do that? Thanks! In a form, how do I define a radiobutton so that when it is selected additional form fields ara loaded onto the same page holding the text in other fields? I am using Frontpage 2003 to build my site. Is there a way to prevent text (like a link) from being selected? I use +/- headers that expand or contract a paragraph, but when clicked rapidly the text is selected. The same thing for images? Robert Hi, I have an album which has 5 to 6 audio files(wma). I used checkboxes to list the audio files. I want to select one or more of the audio files by ticking in checkbox and play those selected using a button. How can I do that using html? I see that many music sites use this functionality, but not sure how to code this using html? Can someone help? Note: I have already hosted the audio files and have the web url for all the wma files. |