JavaScript - Taking A Part Of All Url Value
Hi,
I have youtube link saved as a variable with value: PHP Code: http://www.youtube.com/watch?v=oOzuBOefL8I&feature=topvideos And I need to get a part of this link which I could use later: The part would be PHP Code: oOzuBOefL8I It would be great to do it with javascript... Because I have url generated like this one: PHP Code: httpObject.open("GET", "../talpinimas.php?id=reklama&paveikslelis=" +document.getElementById('paveikslelis').value+"&pavadinimas=" +document.getElementById('pavadinimas').value+"&url1=" +document.getElementById('url1').value+"&url1name=" +document.getElementById('url1name').value+"&komentaras=" +document.getElementById('komentaras').value+"&nick=<?php echo $nick?>" , true); and I want to send just THE PART (oOzuBOefL8I) to my talpinimas.php page. If you haven't understood something or need more info ask... Thanks Similar TutorialsI'm probably missing something really obvious here, but I can't figure out how to get this to work. I'm trying to get a tooltip to work, as shown he http://jquerytools.org/demos/tooltip/index.html this is where I got the basic code for the javascript and the css styling, and I've put it all together in the way that I think it should work, but instead of creating a tooltip, it basically opens the content on a separate page. Would anyone be able to look at the source code for the website below and tell me if I'm missing something here? http://boardemotion.co.uk/test.html Any help would be really appreciated hi all, i have written a code for simple shopping cart with 4 items.when i selecting the quantity and clicking the add to cart button it is not taking the values.it is displaying the array values what i have given.kindly tell me what is the problem and how to solve it... below is my "index.html" [HTML] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> JavaScript jQuery</title> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="js/jquery-1.6.2"></script> <script type="text/javascript"> $(document).ready(function() { // call the cart function $("#sc_cart").smartCart(); }); </script> <!--<link rel="stylesheet" type="text/css" href="css/cart.css" /> --> </head> <body> <center><h2>Select Your products</h2></center> <form method="post" action="results.php"> <div id="smartcart" class="Container"> <!-- open "contanier" class --> <div id="sc_productlist" class="ProductList"> <!-- open "ProductList" class" --> <div class="ProductListItem"> <!-- open apple Iphone --> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="images/product0.jpg" /></td> <td><strong><span id="prod_name100">Apple IPhone 3G</span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price100" style="color:red">1450.75</span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="Text" id="prod_qty100" size="3" type="text"> <input type="button" rel="100" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <!-- close apple iphone --> <hr/> <div class="ProductListItem"> <!-- open icepot --> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="images/product1.jpg" /></td> <td><strong><span id="prod_name101">Ice Pot</span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price101" style="color:red">10.25</span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="Text" id="prod_qty101" size="3" type="text"> <input type="button" rel="101" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <!-- close icepot --> <hr/> <div class="ProductListItem"> <!-- open "ProductListItem" style stand --> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="images/product2.jpg" /></td> <td><strong><span id="prod_name102">Style Stand</span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price102" style="color:red">6.15</span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="Text" id="prod_qty102" size="3" type="text"> <input type="button" rel="102" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <!-- close style stand--> <hr/> <div class="ProductListItem"> <!-- for coffee maker --> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="images/product3.jpg" /></td> <td><strong><span id="prod_name103">Coffe Maker</span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price103" style="color:red">120.35</span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="Text" id="prod_qty103" size="3" type="text"> <input type="button" rel="103" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <!-- close coffee maker --> <!-- end "ProductList" class" --> <!-- cart list--> <div id="sc_cart" class="Cart"> <select id="product_list" name="product_list[]" style="display:none;" multiple="multiple"> </select> <div class="CartListHead"> <table width='50%'> <tr> <td width='100px'>Product</td> <td width='100px'>Quantity</td> <td width='150px'>Amount($)</td> </tr> </table> </div> <div id="sc_cartlist" class="CartList"> </div> <div class="CartListHead"> <table width='100%'> <tr> <td><span id="message"></span></td> <td width='100px'>Subtotal($):</td> <td width='120px'><span id="subtotal"></span></td> </tr> </table> </div> </div> <br> <input style="width:200px;height:35px;float:right;" type="submit" class="Btn" value="Checkout"> </div> </div> </form> </body> </html> [/HTML] the array elements given here is displaying in the output.how to remove that one.below is my "results.php" Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> JavaScript jQuery</title> <!-- <link rel="stylesheet" type="text/css" href="css/cart.css" /> --> </head> <body> <center><h2>Selected Products</h2></center> <div id="sc_cart" style="width:950px;" class="Container"> <?php // creating product array $product_array = array("100" =>array('product_id'=>'100', 'product_name'=>'Apple IPhone 3G', 'product_price'=>'1450.75', 'product_img'=>'images/product0.jpg'), "101" =>array('product_id'=>'101', 'product_name'=>'Ice Pot', 'product_price'=>'10.25', 'product_img'=>'images/product1.jpg'), "102" =>array('product_id'=>'102', 'product_name'=>'Style Stand', 'product_price'=>'6.15', 'product_img'=>'images/product2.jpg'), "103" =>array('product_id'=>'103', 'product_name'=>'Coffee Maker', 'product_price'=>'120.35', 'product_img'=>'images/product3.jpg')); // get the selected product array // here we get the selected product_id/quantity combination as an array $product_list = $_REQUEST['product_list']; if(!empty($product_list)) { ?> <div class="CartListHead"> <table width='100%'> <tr> <td> Product</td> <td width='80px'>Quantity</td> <td width='130px'>Amount($)</td> </tr></table> </div> <?php $sub_total = 0; foreach($product_list as $product) { $chunks = explode('|',$product); $product_id = $chunks[0]; $product_qty = $chunks[1]; $product_name = $product_array[$product_id]['product_name']; $product_amount = $product_array[$product_id]['product_price']*$product_qty; $sub_total = $sub_total + $product_amount; ?> <div class="CartListHead"> <table width='100%'> <tr> <td> <?php echo $product_name; ?></td> <td width='80px'><?php echo $product_qty; ?></td> <td width='130px'><?php echo $product_amount; ?></td> </tr> </table> </div> <?php } ?> <div class="CartListHead"> <table width='100%'> <tr> <td><span id="message"></span></td> <td width='100px'>Subtotal($):</td> <td width='120px'><span id="subtotal"><?php echo $sub_total; ?></span></td> </tr> </table> </div> <br> <form action="index.php" method="post"> <?php if(isset($product_list)) { foreach($product_list as $p_list) { $prod_options .='<input type="hidden" name="product_list[]" value="'.$p_list.'">'; } echo $prod_options; } ?> <input style="width:200px;height:35px;float:left;" type="submit" class="Btn" value="Continue Shopping"> </form> <?php } else { echo "<strong>Your Cart is Empty</strong>"; } ?> </div> </body> </html> here too below is my "index.php"..... Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> JavaScript jQuery </title> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { // call the cart function $("#sc_cart").smartCart(); }); </script> <!--<link rel="stylesheet" type="text/css" href="css/cart.css" /> --> <?php // creating product array $product_array = array("100" =>array('product_id'=>'100', 'product_name'=>'Apple IPhone 3G', 'product_price'=>'1450.75', 'product_img'=>'images/product0.jpg'), "101" =>array('product_id'=>'101', 'product_name'=>'Ice Pot', 'product_price'=>'10.25', 'product_img'=>'images/product1.jpg'), "102" =>array('product_id'=>'102', 'product_name'=>'Style Stand', 'product_price'=>'6.15', 'product_img'=>'images/product2.jpg'), "103" =>array('product_id'=>'103', 'product_name'=>'Coffe Maker', 'product_price'=>'120.35', 'product_img'=>'images/product3.jpg')); // get the product list $product_list = $_REQUEST['product_list']; $prod_options =''; if(isset($product_list)){ foreach($product_list as $p_list){ $prod_options .='<option value="'.$p_list.'" SELECTED></option>'; } } ?> </head> <body> <center><h2>Select Your products</h2></center> <form action="results.php" method="post"> <div id="smartcart" class="Container"> <div id="sc_productlist" class="ProductList"> <?php foreach($product_array as $p) { ?> <div class="ProductListItem"> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="<?php echo $p['product_img']; ?>" /></td> <td><strong><span id="prod_name<?php echo $p['product_id']; ?>"><?php echo $p['product_name']; ?></span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price<?php echo $p['product_id']; ?>"><? echo $p['product_price']; ?></span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="scText" id="prod_qty<?php echo $p['product_id']; ?>" size="3" type="text"> <input type="button" rel="<?php echo $p['product_id']; ?>" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <?php } ?> </div> <div id="sc_cart" class="Cart"> <select id="product_list" name="product_list[]" style="display:none;" multiple="multiple"> <?php echo $prod_options; ?> </select> <div class="CartListHead"> <table width='100%'> <tr> <td> Product</td> <td width='80px'>Quantity</td> <td width='140px'>Amount ($)</td> </tr> </table> </div> <div id="sc_cartlist" class="CartList"> </div> <div class="CartListHead"> <table width='100%'> <tr> <td><span id="message"></span></td> <td width='100px'>Subtotal ($):</td> <td width='120px'><span id="subtotal"></span></td> </tr> </table> </div> <br> <input style="width:200px;height:35px;float:right;" type="submit" class="Btn" value="Checkout"> </div> </div> </form> </body> </html> kindly tell me where went wrong and how to solve it....... hi guys, as im still a noob at javascript, so im asking for your help, i didnt make this script, someone else did and i asked for their permission to change it to my needs, the problem is, i have it working for times that are over an hour long, but i need to also make it possible to display in just under an hour aswell, eg instead of 01:00:00 it would display 60:00 then 59:59 eg, so basically im asking, how can i take the hours out of this, without it currupting the entire JS? Code: var HAS_EXPIRED = 'Time has Expired!'; var IS_NONE = 'None'; function secondCountdown(s){ if(s){ var timeleft = document.getElementById('timeleft').innerHTML; if((timeleft == HAS_EXPIRED) || (timeleft == IS_NONE)) return false; timeleft = timeleft.replace('<font>', ''); timeleft = timeleft.replace('</font>', ''); var time = timeleft.split(":"); var secs = time[2] * 1; var mins = time[1] * 1; var hrs = time[0] * 1; secs += (mins * 60) + (hrs * 3600); secs -= 1; if(secs <= 0){ document.getElementById('timeleft').innerHTML = HAS_EXPIRED; return false; } else { hrs = Math.floor(secs/3600); secs -= (hrs * 3600); mins = Math.floor(secs/60); secs -= (mins * 60); if(hrs < 10) hrs = '0' + hrs; if(mins < 10) mins = '0' + mins; if(secs < 10) secs = '0' + secs; document.getElementById('timeleft').innerHTML = hrs + ':' + mins + ':' + secs; } } setTimeout('secondCountdown(true)',1000); } bootloaderAdd('secondCountdown()'); bootloaderOn(); Cheers. Dan Hey all - I need a java bookmarklet that does a real simple thing. I need to take the current URL (ie, where the user is when they click the bookmarklet) and append it to a static URL and return the text on the resulting page. For example: The user is at http://google.com The user clicks the bookmarklet. the bookmarklet takes http://google.com and appends it to http://example.com/outside_create.ph...ey=555&url=URL HERE where you see the URL HERE text. That PHP script echos a simple line of text (a shortened URL actually). Then I want that result from the outside_create.php file to be displayed in a window back to the user. Is this even possible? Basically I need to know how to append location.href to a static URL and how to get the resulting content from the static URL.. I am creating a website for someone and can get information from one form to check it so it can then change the data in another form. This what I have for JavaScript: <script type="text/javascript" language="JavaScript"> function price() { if(document.cust.top.value == None && document.cust.swirl.value == None) { document.price.hosted_button_id.value = "UDNNKUHTPGEEW"; } else { document.price.hosted_button_id.value = "CP8EVFLEASF28"; } } </script> The result I want is to take the value from my form that has a radio buttons and check to see if it equal none or not. Then using that information change the value in a different form. The first form looks like this for beginning: <form name="cust" method="get" action=""> hello you wonderful informative folks helped me make a resume site for myself some time ago i have since lost the username for ftp access to the site and remade it with paid hosting instead of free hosting, with my own domain name and everything the old site was number 2 for searching for patrick allard on google, but the new site is far down the list new site: http://patrickallardcomputerwhiz.com/ ive tried contacting the free hosting provider, trying to get him to delete the site or relink it, even giving him the password and offering $10 as i expected the customer service on free hosting isn't top notch does anyone have any ideas on how i might fix this? I am having some trouble with my code in that I am trying to take the value from the date of birth field and check to see if over 18 years old. I they are not over 18, a window.alert dialog box pops up to tell them. Any help with this I would greatly appreciate. Below is the check if 18 validation. Script section in the document head: Code: //check if over 18 function overAge(){ var age; var input = document.forms[0].birthDate.value; var pyear = parseInt(input.substring(6,10)); var pmonth = parseInt(input.substring(0,2)) - 1; var pday = parseInt(input.substring(3,5)); if ( month < pmonth ){ age = year - pyear - 1; } else if ( month > pmonth ){ age = year - pyear; } else if ( month == pmonth ){ if ( day < pday ){ age = year - pyear - 1; } else if ( day > pday ){ age = year - pyear; } else if ( day == pday ){ age = year - pyear; } } if(age < 18){ window.alert('Attention: Under 18!'); valid=false; return valid; } } Code for body section: Code: Date of Birth: <br/> <input type = "text" name = "date" value = "(mm/dd/yyyy)"/> hello everybody! this is my first atempt in writing javascript and i have a problem which I have no idea how to solve. I want to take the values from several dropdown forms and make some calculations whit those in order to display a number. Unfortunately the script responts in a way that i cannot identify what is happening. this is a shorten example of my script. Code: <html> <head> <script type="text/javascript"> function calcul() { var pcno = document.plithospc.listplpc.value; var ndno = document.plithosnd.listplnd.value; var hotline = document.hotlform.listhotl.value; var sumhotline = 0; if (hotline == 2) { sumhotline = 8*(1+0.5*pcno) + 2*(1+0.5*ndno); } else if (hotline == 3) { sumhotline = 16*(1+0.5*pcno) + 4*(1+0.5*pcno); } else { sumhotline = 0; } document.write(sumhotline); </script> </head> <body> <FORM NAME="plithospc"> <SELECT NAME="listplpc"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>-1-</OPTION> <OPTION VALUE=2>-2-</OPTION> <OPTION VALUE=3>-3-</OPTION> </SELECT> <FORM NAME="plithosnd"> <SELECT NAME="listplnd"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>-1-</OPTION> <OPTION VALUE=2>-2-</OPTION> <OPTION VALUE=3>-3-</OPTION> </SELECT> <FORM NAME="hotlform"> <SELECT NAME="listhotl"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>1st selection</OPTION> <OPTION VALUE=2>second selection</OPTION> <OPTION VALUE=3>third selection</OPTION> </SELECT> <button type="button" onclick="calcul()">click me</button> </body> does anyone knows how to fix this? thanks in advance Hi Exprts, I am using a (anylink)javascript menu from dynamic drive. Basically I am having a design issue but posting the problem here because I think this can be fixed through JS. Please download the attached files. You will see the menu & the sub menu on mouse over. Problem is that.... when the submenu appears & I take my mouse to the sub menu, the parent item hover style disappears. I mean, it doesn't look active. I just want the parent item active when users moves his/her mouse to sub menu. Thats all. Please suggest me any solutions for this. Thank you in advance. css: Code: #nav{ width: 960px; margin: 0 auto; } ul li{ float: left; margin-right:50px; list-style: none; } .sub-menu{ display: none; } jquery code: Code: $(function(){ ("#nav ul li").hover(function() { (".sub-menu").css("display","block"); }); html code: Code: <div id="nav"> <div class="left"></div> <div class="right"></div> <ul> <li><a href="/" class="current">Home</a></li> <li><a href="/cpanel.html" class="">cPanel</a> <div class="sub-menu"> <h2>test</h2> <p> <a href="#">test</a> <a href="#">test</a> <a href="#">test<</a> </p> <p> <a href="#">test</a> <a href="#">test</a> <a href="#">test<</a> </p> </div> i am sorry, i am new of jquery.i want to show the sub nav part when the mouse hover on the `li` part. but my code doesn't work.how to correct it. thank you My problem is relates to getting part of the text from a div, then pass this on to a variable which then acts upon it. This is a short summary in detail: http://jsfiddle.net/defencedog/W9Fsw/ Above simulates a Forum like environment (PHPBB3). here user can't insert html in posts thus a customised BBcode ([doc])is made in which is placed the required src attribute, unique to every SCRIBD document. The goal is to get the text within the two [doc] & that will be something like (discarding the two BBCodes) Code: src="http://www.scribd.com/embeds/2942002/content?start_page=1&view_mode=list&access_key=key-sxlnrfvqu5s22kzi5xb" then pass it on as a variable named src, which will then replace the contents to achieve desired output. Notice the two problems 1] how do I select the div upon which the action is to take place I.e that contains [doc]. Remember there occurs other divs as well in a posted message? 2] How do I select the desired text? Plz do giv me some suggestions I'm trying to figure out how to split a url variable... I tried these two ways, with an alert to see my result, but I'm not getting anything. Suggestions? Code: function() { myURL = "http://www.test.com/folder1/folder2/someone" var partsA = myURL.split("//"); var parts = partsA[1].split("/"); alert(parts[2]); } Code: function() { myURL = "http://www.test.com/folder1/folder2/someone" var parts = myURL.split('/'); var result = parts[parts.length-2] + '/' + parts[parts.length-1]; alert(result); } I got some updates on my progress... still no results. (quoting my previous thread) Quote: I need desperate help with a homework! Here's the task: First of all I need to define an array of 3 elements. Each element is associated with a different first name. Then I shall realize a first function to add a name in the table. The function takes as parameter the table previously created and return it containing an additional element whose value is the name that the visitor wants to add. I must use the dialog box prompt so that the user can specify the name he wishes to add in the table. I shall also perform a second function which will display the name that is included in the different array elements. This function will also take the table in parameters and proceed with setting the display name with a dialog box alert type that contains all of the name separated by ";". Here's what I've done so far: Code: <html> <head> <title> Task #4 </title> </head> <body> <script language="javascript"> function addName() { var names=new Array(3); names[0]="John"; names[1]="Patrik"; names[2]="Jane"; document.open(); document.write(names[3].join()); document.close(); if(names==new Array); { prompt("What name do you want to add?"+""); } return addName } </script> <noscript> <h1> You're browser doesn't support Javascript </h1> </noscript> </body> </html> Updates: Code: <html> <head> <title> Task #4 </title> <script language="javascript"> function addName() { var names=new Array(3); names[0]="John","Brian"; names[1]="Patrik","Gene"; names[2]="Jane","Sophie"; document.open(); document.write(names.join(";")); document.close(); if(names==new Array); { var addToArray=prompt("What name do you want to add?","") names.push(addToArray) } } function displayNames(addName) { alert(addName); } </script> <noscript> <h1> You're browser doesn't support Javascript </h1> </noscript> </head> <script language="javascript"> <body onLoad="displayNames(addName)"> </body> </script> </html> I've got an idea for simplifying my code and avoid a bunch of switch functions but don't know how, though I assume it's possible. How do I write a function to change/insert only part of an img src? in other words something along the lines of if url contains: "/folder1/folder3/"; change this to: "/folder1/ folder2 /folder3/"; I have a situation in which I have to track clicks (links etc..). The problem is, I have a larger div ie - parentDiv - like 300px height, 400px width - approximate. This div has a background image. Now, the issue arises because over this div (parentDiv), I have another div "announceDiv" on top of it showing information. I ONLY want the parts of parentDiv that is NOT covered by announceDiv to be clickable. Just to reiterate, I have a big div that I want clickable (so I can add a link to the click), but over this big div I have a smaller div showing content ie, information, that links to its own stuff. BUT I want to be able to link from this background image that is in the parentDi without affecting when I click in the smaller div that is superimposed over it. any ideas? has to work in ie6+ and ff 3+ I'm sure this is probably a simple question, but I'm going to ask anyway. I need to extract part of a URL and place it into a variable for use elsewhere on the page. The part to be extracted will be of varying lengths. As an example, if I have the following URL: http://more.stltoday.com/stltoday/st...e?OpenDocument I need to extract "SS". Basically, anything that appears between "static.nsf/" and "/Steve's_APT_test_page". That value needs to be put into a variable and called elsewhere on the page. For testing purposes, I'm using the following code, just to see if it works (which, so far, it doesn't): Code: <script type= type="text/javascript" language="javascript"> var page_url = window.location.href; var segments = page_url.split("/"); alert(segments[4]); </script> Can anyone help? Thanks, Steve Hello I needed an interdependent form for my website and found a JavaScript that would do the trick. Now i have no knowledge in JavaScript but i managed to set this up right. But i seems some part of the script makes a popup window which is showing what is chosen in the form and i reeeally want to remove that Can anyone pick out which piece of the script i need to remove? Thanks in advance Code: var ss2Values = [ // 'Please choose a subject' ['Please choose a category'], // '3D Printer' ['Please choose a category', 'Darwin', 'Huxley', 'MendelMax', 'Original Mendel', 'Printrbot', 'Prusa Mendel', 'Wallace', 'Upgrades'], // 'Home' ['Please choose a category', 'Bathroom', 'Bedroom', 'Decorations', 'Furniture', 'Home utilities', 'Household items', 'Kitchen', 'Livingroom', 'Outdoor', 'Spareparts'], // 'Mechanical' ['Please choose a category', 'Gears', 'Nuts and bolts', 'Tracks and bogies'], // 'Electrical' ['Please choose a category', 'Battery boxes', 'Terminal blocks', 'Outlet boxes'], // 'Electrical' ['Please choose a category', 'Architectural', 'Games', 'Ornaments', 'Toys'], // 'Educational' ['Please choose a category', 'Biological models', 'Chemical models', 'Mathematical', 'Physical models'] ]; window.onload = function() { var ss2 = new xSubSelect('sel20', 'sel21', null, ss2Values, ss2OnChange); } function ss1OnChange(s0, s1, s2) { alert( s0.options[s0.selectedIndex].value + ' / ' + s1.options[s1.selectedIndex].value + ' / ' + s2.options[s2.selectedIndex].value ); } function ss2OnChange(s0, s1) { alert( s0.options[s0.selectedIndex].value + ' / ' + s1.options[s1.selectedIndex].value ); } function xSubSelect(sSelId0, sSelId1, sSelId2, aValues, fnOnChange) { var s0 = document.getElementById(sSelId0); var s1 = document.getElementById(sSelId1); var s2 = sSelId2 ? document.getElementById(sSelId2) : null; if (s0 && s1) { s0.onchange = function() { var i, len, val; // clear existing options for s1 len = s1.options.length; for (i = 0; i < len; ++i) { s1.options[0] = null; } // insert new options for s1 len = aValues[s0.selectedIndex].length; for (i = 0; i < len; ++i) { val = aValues[s0.selectedIndex][i]; s1.options[i] = new Option(s2 ? val[0] : val); } // update s2 if (s2) { s1.onchange(); } }; if (s2) { s1.onchange = function() { var i, len; // clear existing options for s2 len = s2.options.length; for (i = 0; i < len; ++i) { s2.options[0] = null; } // insert new options for s2 len = aValues[s0.selectedIndex][s1.selectedIndex].length; for (i = 1; i < len; ++i) { s2.options[i - 1] = new Option(aValues[s0.selectedIndex][s1.selectedIndex][i]); } }; s2.onchange = function() { if (fnOnChange) { fnOnChange(s0, s1, s2); } }; } else { s1.onchange = function() { if (fnOnChange) { fnOnChange(s0, s1); } }; } s0.onchange(); // first init } } Hi This is for a class project, for some reason only the first part is working. The (sales*.20) and all of my else if are not. Kind of stuck on this. Code: <script type="text/javascript"> function bonus() { var sales var excellent var good var fair var poor sales= document.workBonus.txtSales.value; sales= parseInt(sales); excellent= document.workBonus.chkExc.value; good= document.workBonus.chkGood.value; fair= document.workBonus.chkFair.value; poor= document.workBonus.chkPoor.vaule; if (sales && excellent) { alert(sales * .20) } else if (sales && good) { alert(sales * .10) } else if (sales && fair) { alert(sales * .05) } else if (sales && poor) { alert(sales * .01) } } </script> Hi all I am new here, hopefully someone can assist me with the following... If I have ../PACKAGES/test/run.html stored in the variable myUrl and I want to extract whatever is between ../PACKAGES/ and /run.html how would I go about it? I understand that in this instance I could use: var actualUrl = myUrl.slice(12,16); but the length of the string is dynamic, the only parts that stay the same are the start (../PACKAGES/) and end (/run.html). I am new to java-script, so please be kind...any assistance would be much appreciated. hello i need help in deleting a code part, like: table, ul ... the problem is that when i use rss feeds, lot of them add some code parts that i don't need like: <ul class="similar-topics">, and it shows similar topics so, i want to remove this code part from the rss feed i think that i may add a javascript code to the rss template that brings the rss feeds, so as it remove the part i define i hope you help me doing this, even with another idea another idea is to use: http://pipes.yahoo.com i"m sure there is a way to cut parts from the code, but i couldn't get it yet and i'm still trying Regards |