JavaScript - Sending Option Value In Php
HI All,
I am using triple ajax dropdwon in my php file.In my form i have species_scientifc_name & on select I am sending its id to a php file for retriving data for second dependent dropdown box, Here I need to get this id in form action file. How to get this value, Any idea? Thnaks in Advance!! Similar TutorialsYou've probably seen this many times with two dynamic linking select boxes that deals in form or another deal with countries and then cities for the second one or something similar well I have another question about that. I've looked at a few others and well their coding is so different then mine that I don't want to use code for my own project that I don't understand in case I need to reuse it for some other reason down the road. The user selects a country and with the users selection it passes the countryid as a variable through jquery's ajax fuction as a post parameter to a php process page in which it goes to a table and matches the country id with the db field called country_id in the arenas table. With all the records that matches that countryid it selects the arena name and city that the arena is in and displays it as an option tag now I'm trying to figure out with muliple entries how can I pass the results back to the form page and insert it into the arenas dropdown box. Following is my coding separated out for you. I only included the necessary parts. All help would be greatly appreciated. form page Code: $('#countryid').change(function() { var countryid = $("select#countryid").val(); var dataString = 'countryid='+ countryid; $.ajax({ type: "POST", url: "processes/booking.php", data: dataString, success: function() { } }); }); <div class="field required"> <label for="countryid">Country</label> <select class="dropdown" name="countryid" id="countryid" title="Country"> <option value="0">- Select -</option> <?php $query = 'SELECT id, countryname FROM countries'; $result = mysqli_query ( $dbc, $query ); // Run The Query while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { print "<option value=\"".$row['id']."\">".$row['countryname']."</option>\r"; } ?> </select> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> <div class="field required"> <label for="arena">Arenas</label> <select class="dropdown" name="arenas" id="arenas" title="Arenas"> </select> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> php process page PHP Code: $countryid = (int)$_GET['countryid']; $query = "SELECT * FROM `arenas` WHERE `country_id` = '$countryid'"; $result = mysqli_query ($dbc, $query); while ($row = mysqli_fetch_array($dbc, $result)) { echo '<option value="'.$row['arena'].'">'.$row['arena'].' - '.$row['city'].'</option>\n'; } Hello all, I am currently looking to create a JavaScript menu for a website I am working on. It currently expands and collapses on click. The code in question is pasted below:- menu_status = new Array(); function showHide(theid){ if (document.getElementById) { var switch_id = document.getElementById(theid); if(menu_status[theid] != 'show') { switch_id.className = 'show'; menu_status[theid] = 'show'; }else{ switch_id.className = 'hide'; menu_status[theid] = 'hide'; } } } As you can see, it basically shows and hides the menu (when clicked). I want it to open the menu when clicked and close when another menu is opened. I have looked and have not been able to find a solution into it. Ideally I donot want it to be a long piece of code as I do have a working menu but with many more lines of JavaScript than the one I have posted. I need a solution to it urgently, your help is appreciated. Thanks Hello according to this http://www.w3schools.com/php/php_ajax_database.asp I prepared mine search which works fine. it displays which products are intel and which amd for example. I wonder how can i add a second similar search for sochet or something else,but not separate one for example if i have selected the intel as 1st option then choosing my 2nd one it display only intel products. Here is my current code: Code: <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","kailoipa.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <select name="products" onchange="showUser(this.value)"> <option value="">Select a person:</option> <option value="intel">intel</option> <option value="amd">amd</option> </select> </form> <br /> <div id="txtHint"><b>Person info will be listed here.</b></div> </body> </html> Hey guys, I recently found a small code in internet which use option value in select tag to insert value in text box, so text box has the exact same value as selected option: Code: <form name="theform" onsubmit="CheckForm()"> <select name="myOptions" onchange="document.theform.showValue.value=this.value"> <option name="(some dynamic text)" id="(some dynamic text)" value="I am the first option">I am the first option</option> <option name="(some dynamic text)" id="(some dynamic text)" value="I am the second option">I am the second option</option> <option name="(some dynamic text)" id="(some dynamic text)" value="I am the third option">I am the third option</option> <option name="(some dynamic text)" id=""(some dynamic text)" value="I am the third option">I am the fourth third option</option> </select> <input type="text" name="showValue"><br> </form> Now what I want is simple and a little different from this one, I want the text box value to be as exact as selected option name or id (doesn't matter which one) which means if an option selected, text box value has to follow that option name or id. Thanks folks. Hi!, I use this option transfer example for my php& mysql web... http://www.developergeekresources.co...to_listbox.php I wanted to know how can i get a value from this ? as a example i need to get first 3 values after transferred.... How can i do this ? Thanks Hi Guys, A bit stuck here and was wondering what you guys think. I have an HTML Select Option with a list of countries. A user saves that page and when he wants to return to the same page later at some point, i would like to populate the countries drop down list with what he entered initially. Is there an easy way to do this? Thanks. I have some code for a dropdown where when the 'Other' option is selected a textbox appears and the user can put in their info. What I'm wondering is, how can i set it up so if the Other option isn't selected the dropdown info is sent to my database Name field, and if the Other option is selected it sends the info that's typed in to the Name field in my database and does nothing with the actual 'Other' label in the dropdown? here's the code i have so far Code: <script language="JavaScript" type="text/javascript"> <!-- function getOther(sel,fld){ fld.style.display = (sel.selectedIndex==sel.options.length-1)?"inline":"none"; } //--> </script> <select name="Name" id="Name" onchange="getOther(this,this.form.oth);"> <option>Name 1 <option>Name 2 <option>Name 3 <option>Name 4 <option>Name 5 <option>Other </select> <br><input type="text" name="Other" style="display: none;"> Hi All, I need to replace the dropdown option values when a different dropdown value is changed. I am calling the javascript function with onChange successfully, but I'm struggling to make the changes. Original Code: <select name="People"> <option value="A">Person A</option> <option value="B">Person B</option> <option value="C">Person C</option> </select> Change to Code: <select name="People"> <option value="X">Person X</option> <option value="Y">Person Y</option> <option value="Z">Person Z</option> </select> Can someone provide an example? Thanks You in Advance for Your Help! Hi, I have a select box whose options are populated from an xml file, the code goes like this: Code: var sel_html = '<select onChange="handleSelected(this)">' + '<option selected> - Select a zone - <\/option>'; var a = 0; function createPolygon(pts,colour,name) { var shape = new GPolygon(pts,"#000000",1,1,colour,0.5, {title:name}); gpolygons[a] = shape; // ======= Add the entry to the select box ===== sel_html += '<option> ' + name + '<\/option>'; // ========================================================== a++; return shape; } // ======= This function handles selections from the select box ==== // === If the dummy entry is selected, the info window is closed == function handleSelected(opt) { for (var a=0; a<gpolygons.length; a++) { gpolygons[a].hide(); } var a = opt.selectedIndex - 1; if (a > -1) { gpolygons[a].show() } } sel_html += '<\/select>'; document.getElementById("selection").innerHTML = sel_html; which works fine for showing one option at a time, but what I would like to do is have one of the selections to be to show all of the options at the same time. At the moment I have it working with a checkbox that works off a separate piece of code, but it would be great to have that option within the select box. You can see the select box in question here - it's the one on the right which says "Select a zone" thanks in advance. Hello. Could anyone help me with this? I understand how to use OnChange with select boxes to allow the page to be redirected when certain options are selected, such as; Code: <select onchange="window.open(this.options[this.selectedIndex].value,'_top')"> <option value="">Choose a destination...</option> <option value="http://www.yahoo.com/">YAHOO</option> <option value="http://www.google.com/">GOOGLE</option> <option value="http://www.altavista.com/">ALTAVISTA</option> <option value="http://www.amazon.com/">AMAZON</option> <option value="http://artlung.com/">ARTLUNG</option> </select> However, I would like the page to only be redirected when just one option (out of 3) are chosen... and when the other two are chosen, we remain on the same page. such as; Code: <select onchange="window.open(this.options[this.selectedIndex].value,'_top')"> <option value="">Choose an option...</option> <option value="tonight">TONIGHT</option> <option value="tomorrow">TOMORROW</option> <option value="http://mysite.com/selectdate">SELECT DATE</option> </select> is this possible? Many Thanks, Patrick. Hello Everyone! It's been a while since this thought started to bother me, I would like to create a website that has script which depending on the option chooses the image and merges with the other image. My idea is that someone comes on my website which would be custom carp hair rings. They would have options such as: Hook type Hook size Braid(fishing line) Length of the braid Swivel So depending on the hook they choose different image will appear and depending on the braid and the hook size everything merges together into finished product where the outcome you could clearly see the image of the hook tied with braid and a swivel at the end. This is the image Basically where you see the hook, the customer could select from an option of hooks and it would be replaced by their option, the length of the bread doesn't matter, but it would be nice to have some sort of an indicator to the customer how long it would be, and the last bit is the swivel, depending on the option the customer chooses, he can see the swivel or not. Its like creating your own carp rig, you choose which hook you want, then it appears, you choose which braid you want, it appears and if you want you can have a swivel at the end and you can see how your chosen options looks like in reality. Now I do not ask anyone to do everything for me, all I'm asking is for directions. Is there a script somewhere that I could edit that would achieve my goal, since I have no coding skills but some knowledge it would be nice to get some support along the way. Thank You for you attention Arnoldas Valys I am trying to make some option buttons that will change the background of the document.I have already styled the body with an image using document.body.style.background I am now trying to make some option buttons that will make the background repeat or be placed to the center. Here are the buttons: Code: <select> <option type="button" selected="selected" onclick="tile()">Tile</option> <option type = "button" onclick = "center()" >Center</option> </select> And the functions: Code: function tile() { document.body.style.backgroundRepeat="repeat"; } function center() { document.body.style.backgroundRepeat="no-repeat"; document.body.style.backgroundPosition="center"; } However it doenst work Hi, I've currently got a group of dropdowns that update a price total on my site. I want to add an 'add to cart' button too but this requires each drop down having 2 values (one to update total and one to go towards the 'add to cart button'). I've researched this but still have no idea how to go about getting 2 values from one dropdown though. What I've done is create an explanation page where I have one form for the running total, and then a completely seperate form for the add to cart. Both work independanly, but I want to effectively combine them. Here's the page: tigerfrog.co.uk/merge_codes.html code for running total is: Head Code: <script language="JavaScript" type="text/javascript"> function calc2(){ var totalStr = ''; // for testing only var totalValue=0; var DDL; var cnt = 0; // for testing only for (var j=1; j<=2; j++) { DDL = document.getElementById('dropDownList'+j); temp = DDL.options[DDL.selectedIndex].value; totalValue += Number(temp); if (DDL.selectedIndex != 0) { totalStr += '|'+temp; cnt++; } // cnt++ is for testing only } document.forms[0].total.value=totalValue; } </script> Body Code: <form id="dropDownForm2" name="dropDownForm2"> <td class="style14"> <select id="dropDownList1" class="style10" name="D10" onchange="calc2();"> <option selected="" value="10">item1</option> <option value="20">item2</option> <option value="30">item3</option> </select> <br /> </td> <td class="style14"> <select id="dropDownList2" class="style10" name="D11" onchange="calc2();"> <option href="alloy.htm" selected="" value="11">item4</option> <option value="12">item5</option> <option value="13">item6</option> </select><br /> total </td> <input class="style10" name="total" onfocus="blur()" readonly="" size="4" style="width: 46px; height: 22px;" type="text" value="958" /></form> The code for the add to cart is: Code: <form action="http://www.romancart.com/cart.asp" method="post"> <input name="storeid" type="hidden" value="43579" /> <input name="itemcode" type="hidden" value="TF Series" />Frameset <select name="itemname2"> <option value="TF100" value="TF100">item1</option> <option value="TF300C" value="TF300">item2</option> <option value="TF400C" value="TF400">item3</option> </select><br /> Groupset <select name="itemname5"> <option value="SL T1" value1="SL T1">item4</option> <option value="SLR T1" value1="SLR T1">item5</option> </select><br /> <input type="submit" value="Add to basket" /> </form> If I had 2 values from each drop down in the first group of dropdowns then I could get it working, but I'm not sure how to do this. Any help will be great, Phil How to add title to options in Select box , where the options are generated from the data base. Any idea Hello, I have some database widgets. I want the user to be able to mouseover the widget and see a popup window of a synopsis of the database. If the user would like to access the database, I would like them to have the onClick option. <head> [CODE] <script> function openPopUp(URL) { new_window = window.open(URL, 'window', 'toolbar=0,scrollbars=0,location=0, statusbar=0,menubar=0,resizable=0,width=650,height=300,left = 350,top = 280'); } function closePopUp() { new_window.close(); } </script> [CODE] <Body> [CODE] <a href="#" onMouseOver="openPopUp('http://jpl.coj.net/res/db/popups/abc-clio.html')" onMouseOut="closePopUp(''http://jpl.coj.net/res/db/popups/abc-clio.html')"><img src="http://jpl.coj.net/pics/logos/abc-clio.jpg" alt="ABC-CLIO Databases" width="164" height="42" border="0"/></a> <URL of database> http://databases.abc-clio.com/Multi/ Can this be done? Thank you for your help, Elbee hey there i was wondering if anyone knows how to get a print option button in a pop up window , i am using html with javascript to create a currency converter i have a button on my main page which opens up a popup window with information taken and totalled from the user input , i would like to be able to offer the option to print this window off . code is function open_win(){ myWindow=window.open('','','width=300,height=300'); myWindow.document.write("<p>Current sterling recieved</p>",sterling_total,"<p>Total commision recieved</p>",commision_total,"<p>Total Money Recieved</p>",running_total); myWindow.focus(); } So I have two for loops that check to see if each array item * a number returns a decimal. Here is my code(Cred to Philip M): Code: var myArray = f; for (var wi=0; wi<myArray.length; wi++) { var warray = myArray[wi]; var wabs = Math.abs((warray*z1)) if (!(wabs > Math.floor(warray)) && (wabs < Math.ceil(warray))){ break; } else{ warray = 1; break; } } for (var yi=0; yi<myArray.length; yi++) { var yarray = myArray[yi]; var yabs = Math.abs((yarray*z2)) if (!(yabs > Math.floor(yarray)) && (yabs < Math.ceil(yarray))){ break; } else{ yarray = 1; break; } } I have two options (I don't know which one is easier because I am clueless about loops) Option 1: Basically I want to find warray, and I want to find yarray, and then once I have found them, I want to check if they multiply to be x If they don't, try again and eliminate the option. In other words: I need to try every combination of numbers in the array until I find two numbers that aren't decimals when they are multiplied by "z1" or "z2" and they both multiply to be "n" Option 2: Find a number for warray that isn't a decimal. Set yarray = (a/warray). If that number * z2 isn't an integer, find warray again, but eliminate the option that didn't work. Thank you so much! i have a archive of data that i want to be loaded in iframes since i have reached a length limit within that page. so what i have is a script that put in a value into a text area, but now i am trying to convert it to putting an src value inside an i frame. i am not the best with javascript so any help would be great. Code: <script type="text/javascript"> function ddl_changed(obj) { var pr = prim.options[prim.selectedIndex].value; var s1 = document.getElementById('s1'); s1.src = pr; } </script> body <div class="prim" align="center"> Database <select id="prim" onchange="ddl_changed(this)"> <option value=" ">Choose a data set</option> <option value="/ds2">data set 1</option> <option value="/ds3">data set 2</option> </select> </div> <iframe name="s1" id="s1" src=" "><p id="noframe">Your browser does not support frames</p> </iframe> thanks I have a select box with a few options. When the page loads I need to get the selected option in this select box and alert its inner text. Yet everything I try out on the net that should work wont work in IE, all other browser its fine. Please can someone show me the TRUE and correct way to get the inner text of a option from a select box in IE? Thanks! |