JavaScript - This Is A Little Tricky.. Please Help
i have an admin page with lots of dropdown menus.
on one of them it has lots of colors in but the owner would like to be able to put special car colors in if he needs to. so i said i could have the dropdown menu replace itself with a text input if the value was "other". first of is this even possible and secondly how would i go about this. because of the perl script i have set up i would like the id and name to be the same on the dropdown menu and the text input Similar TutorialsHi there, I'm looking to create something similar to the online javascript terminal located at http://cb.vu I don't know very much about it so I guessed I'd post here and hope to find someone who knows what they're doing. Thanks! I am trying to run a simple replace over some css a user puts into a textarea. I would like to remove all the comments Code: /* MY COMMENT */ I have tried the following to try and escape the forward slashes but to no avail. Code: replace(/\/*(.*)\//g,""); any ideas? Thanks! Hello, I'm pretty new to javascript (I work mostly in AS3 but am starting to learn my way around js) and I'm hitting a wall on an app build I'm working on. The build is pretty simple, I need to combine the values of a selected radio button and a selected drop down field and output a their combined value plus an additional value. This is for a pick your package vacation. A user can combine golfing with a specific location and below I'd like to populate the cost of such a trip. While I am outputting the values of the radiobuttons and input fields, I cannot get these values to combine or select a third value (the cost of the combined values). It's a bit messy but this is what I have so far. Code: <body> <div id="greenBox"> <div id="whiteBox"> <img src="assets/pickAndSaveGetawayPackages.jpg" id="pickAndSave"/> <img src="assets/happyFam.jpg" id="happyFamily"/> <!--Parks Dropdown Menu--> <div id="pickAPark"> <FORM name="dropDown" method="post" action="dummy" id="dropDown"><left> <select name="myList" size="1" onChange="disp_text()"> <option value="default" name="default" id="default" onclick="alertPark();" selected >Pick a Park</option> <option value="p1" name="p1" id="p1">George T. Bagby</option> <option value="p2" name="p2" id="p2">Park #2</option> <option value="p3" name="p3" id="p3">Park #3</option> <option value="p4" name="p4" id="p4">Park #4</option></select></left></FORM></div><!--pick a park--> <!--Packages Dropdown Menu--> <div id="pickAPackage"> <FORM name="radioForm" id="radioExampleForm" method="get" action="" onsubmit="return false;"> <div align="left"><!--Align Left--><br> <label for="number1"><input type="radio" value="Cottage & Canoe" name="number" id="number1"></label> <br> <label for="number2"><input type="radio" value="Lodge & Learn" name="number" id="number2"></label> <br> <label for="number3"><input type="radio" value="Golf Play & Stay" name="number" id="number3"></label> <br> <label for="number4"><input type="radio" value="RV Explorer" name="number" id="number4"></label> <p><input type="button" onclick="alert('Checked value is: '+getCheckedValue(document.forms['radioExampleForm + dropDown'].elements['number']));" value="Submit"> </FORM></div><!--Align Left--></div><!--pick a package--> <div id="infoBox"> </div><!--infoBox--> <img src="assets/toBook.jpg" id="toBook"/> </div><!--whiteBox--> </div><!--greenBox--> </body> and on the js side //Drop Down Menu function disp_text() { var w = document.dropDown.myList.selectedIndex; var selected_text = document.dropDown.myList.options[w].text; alert(selected_text); } //Return value of checked radio button //Return empty string if none are checked, function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } //Do nothing if none of radio buttons are checked //If the given value does not exist, all the radio buttons //Reset to unchecked function setCheckedValue(radioObj, newValue) { if(!radioObj) return; var radioLength = radioObj.length; if(radioLength == undefined) { radioObj.checked = (radioObj.value == newValue.toString()); return; } for(var i = 0; i < radioLength; i++) { radioObj[i].checked = false; if(radioObj[i].value == newValue.toString()) { radioObj[i].checked = true; } } } Anything would be tremendously helpful! Thanks! Hi all, I have a fairly tricky problem: I have an XML feed of some products from a shop. Is there any way to make it so that if a link to 'product 1' (product_id=0001) is clicked then a div appears elsewhere on the page displaying information about that product from the XML feed (eg stock level and price of 0001). However, when a link to 'product 2' (product_id=0002) is clicked then then the information in this div is that of product 2. (ie: not opening a new div elsewhere or over the top of the old one for product 2's info, but actually in the original div, replacing product 1's info. I guess AJAX is the best method?) The reason i want to do this is so that the info displayed in the div is dependant on the link that has been clicked. I will have links to up to a few hundred products on the page so this method would keep the script size and loading times down - not to mention the enormous amount of work of manually coding a new div for each product. In fact... to make it even more complicated i actually want the links themselves (‘product 1’, ‘product 2’ etc…) to be in an iframe but the div to be opened on the parent page... perhaps its best to tackle on thing at a time though! The XML looks like: Code: <Products> <Product> <Main_Category_id>1</Main_Category_id> <Main_Category_Name>products</Main_Category_Name> <Sub_Category_1_id>12</Sub_Category_1_id> <Sub_Category_1_Name>products sub-category</Sub_Category_1_Name> <Product_id>0001</Product_id> <Product_Model>abcde</Product_Model> <Product_Name>Product 0001</Product_Name> <Product_Description> Description of product 1 </Product_Description> <Product_Price>5.00</Product_Price> <Product_Price_Special>0.00</Product_Price_Special> <Product_Currency>GBP</Product_Currency> <Product_Vat_Rate>0</Product_Vat_Rate> <Product_Image>0001</Product_Image> <Product_Image_Url> http://www.mysite.com/0001.jpg </Product_Image_Url> <Product_Quantity>9999</Product_Quantity> <Product_Weight>0.12</Product_Weight> <Product_Status>1</Product_Status> <Product_Manufacturer/> <Product_Last_Modified/> <Product_Date_Available/> </Product> <Product> <Main_Category_id>1</Main_Category_id> <Main_Category_Name>products</Main_Category_Name> <Sub_Category_1_id>12</Sub_Category_1_id> <Sub_Category_1_Name>products sub-category</Sub_Category_1_Name> <Product_id>0002</Product_id> <Product_Model>abcde</Product_Model> <Product_Name>Product 0002</Product_Name> <Product_Description> Description of product 2 </Product_Description> <Product_Price>10.00</Product_Price> <Product_Price_Special>0.00</Product_Price_Special> <Product_Currency>GBP</Product_Currency> <Product_Vat_Rate>0</Product_Vat_Rate> <Product_Image>0002</Product_Image> <Product_Image_Url> http://www.mysite.com/0002.jpg </Product_Image_Url> <Product_Quantity>9999</Product_Quantity> <Product_Weight>0.12</Product_Weight> <Product_Status>1</Product_Status> <Product_Manufacturer/> <Product_Last_Modified/> <Product_Date_Available/> </Product> Etc… </Products> Thanks for any help at all Matt Hello guys, first post so please be kind. Usually try and find a solution and edit to work for me but this time its a little trickier. I need a script and code that can toggle the contents of a div, while changing the button appearance but !! the button images and content have to be external to the script as the content and images will be loaded from a database on the page and duplicated on page. ideally what I want is say 3 buttons. button1img button2img button3img <// that when clicked control <div id=target><this target content is now set to 2></div> //and toggle between options and only one at a time can be on. The button images and content have to be set outside of the initial script (reason it will be duplicated several times on page) and it cant be a call page 'content1.html' either as it needs to be created from a db on the page. if anyone can help it will be MUCH appreciated, as im pulling my hair out trying to combine 3 different scripts that are all written differently. i understand this is a little trickier, im hoping it is possible. cheers steve |