JavaScript - Help With Javascript-arrows For Increase/decrease
Hi I'm completely stuck, I am looking for placing small
up and down arrows next to my textbox. They would work with by increasing/decreasing number of products. The text box would be active so a client could put the number of a product himself/herself or simply by clicking the up/down arrows next to the text box. I am not sure how to look for it, I mean I thought something like that should exist by default, I search w3c and I can find only combo box etc. Could someone put me on the right track please?.. Similar TutorialsI wish to increase or decrease the size of a div by using + and - buttons how would this be done hi guys im really new to javascript and ive got stuck, function resizeText(multiplier) { if (document.body.style.fontSize == "") { document.body.style.fontSize = "17px"; } document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "5px"; } here is my code it currently incresaes the font size and decreases it with use of 2 buttons on my page, but i want it to only increase in series of 2px at a time with a total of 4 clicks then it must revert to the original size. is that clear ? can anyone help me ? cheers. ant my website is at eduk8africa.org and on the slideshow i need to add arrows to be able to go to the next image. any help code is here : http://pastebin.com/mWNmydQD this needs to be done QUICK! Hi there, I am pretty new to javascript coding, and I could use little help... As you can see here, I got this code where I can move image inside of a box, and I do it by clicking these "links". And now I want to ask you, is there any way that I could move image using keys on keyboard (arrows or WSAD)? I'd like to keep this as simple as possible since I am not really into very advanced scripts (although I could probably understand them if you give little explanation). Code: <html> <head> <body> <script type="application/ecmascript"> // X position of image var x = 0; // Y position of image var y = 0; // Move per click var inc = 10; function Init() { document.getElementById('autic').style.left = x + 'px'; document.getElementById('autic').style.top = y + 'px'; } function moveRight() { x += inc; document.getElementById('autic').style.left = x + 'px'; } function moveLeft() { x -= inc; document.getElementById('autic').style.left = x + 'px'; } function moveUp() { y -= inc; document.getElementById('autic').style.top = y + 'px'; } function moveDown() { y += inc; document.getElementById('autic').style.top = y + 'px'; } </script> <style> #box { width: 500px; height: 300px; position: relative; margin: 20px auto 0px auto; border: 5px outset #000; overflow: hidden; } .image { position: absolute; z-index: 100; } </style> </head> <body onload="javascript:Init()"> <div id="box"><img class="image" id="autic" src="auto.png"/></div> <a href="javascript:moveLeft()">Left</a> <a href="javascript:moveUp()">Up</a> <a href="javascript:moveDown()">Down</a> <a href="javascript:moveRight()">Right</a> </body> </html> Hi, I'm trying to write a function that will show arrowheads on polylines selected from a select box in a google map. I only want the arrowheads that belong to the line shown to be displayed. I have got it working using check boxes, and the select box shows the lines, but am having trouble tweaking the code to get the arrows to show up as well. You can see the working checkboxes (and the semi-working selectbox) he http://www.xelawho.com/map/zonesarrowstest.htm I see the error at line 135 ("Cannot read property 'onclick' of undefined") which I assume refers to the option, but this is where my limited js understanding begins to falter... how do I define the option if the select box options come from xml? And will defining it actually make this code work? Below are (what I think are) the relevant bits of code. Thanks in advance for any help. (cross-posted on the google maps forum and here over the last few days, but unanswered) Code: var h = 0; var v = 0; // === Function to create a marker arrow === function createArrow(point,icon,category) { var arrows = new GMarker(point,icon); map.addOverlay(arrows); pts[v] = arrows; arrows.hide(); arrows.mycategory = category; pts.push(arrows); } var select_html = '<select onChange="handleSelected2(this)">' + "selclick(this)" + '<option selected> - Select a bus route - <\/option>'; function showsel(category) { for (var v=0; v<pts.length-1; v++) { if (pts[v].mycategory == category) { pts[v].show(); } } document.getElementById(category+"option").onclick = true; } function hidesel(category) { for (var v=0; v<pts.length-1; v++) { if (pts[v].mycategory == category) { pts[v].hide(); } } } function selclick(option,category) { if (option.onclick) { showsel(category); } else { hidesel(category); } } function handleSelected2(opt,category) { for (var h = 0; h <gpolylines.length; h++) { gpolylines[h].hide(); } var h = opt.selectedIndex - 1; if (h > -1) { gpolylines[h].show(); } for (var v=0; v<pts.length; v++) { selclick(category); } } GDownloadUrl("allzonesencoded.xml", function(doc) { var xmlDoc = GXml.parse(doc); var lines = xmlDoc.documentElement.getElementsByTagName("line"); for (var i=0; i< pts.length; i++) { var category = lines[a].getAttribute("category"); } // ===== final part of the select box ===== select_html += '<\/select>' ; document.getElementById("selection2").innerHTML = select_html; hi guys im looking for help with a soloution that will enable me to set a divs min-height to 350px then when the window is resized it will increase over that 350 this supose to allow people with larger resoloutions to see more of the content. make sense any ideas? cheers. Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank Does anyone know how to make URL links that use Javascript still work when users have Javascript disabled on their browser? The only reason I'm using JS on a URL is because my link opens a PDF file, and I'm forcing it not to cache so users have the latest version. I tried the <script><noscript> tags, but I'm not sure if I'm using it correctly, as my URL completely disappears. Below is my HTML/Javascript code: <p class="download"> <script type="text/javascript">document.write("<span style=\"text-decoration: underline;\"><a href=\"javascript:void(0);\" onclick=\"window.open( 'http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf?nocache='+ Math.floor( Math.random()*11 ) );\" >The Child Magazines Media Kit</a></span> (PDF 1 MB) ");</script> <noscript><span style="text-decoration: underline;"><a href="http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf" >The Child Magazines Media Kit</a></span> (PDF 1 MB)</noscript> </p> Thanks for any help, Michael Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks Hi, I have the following code snippet: test.html ====== <script language="javascript" type="text/javascript"> var testVariable = "test"; </script> <script language="javascript" type="text/javascript" src="test.js"> </script> test.js ===== var testVariable = window.top.testVariable; In firefox, I'm able to access testvariable defined within test.html in test.js. But in chrome, test.js couldnot get the window.top.testVariable field defined in test.html. Can any one please let me know how i can make it work in chrome?. Am i missing something here?. Hey, I've got to make the values of some textboxes change the co-ordinates of my sprite on a canvas and havent a clue on how to do it, Here is my form with the two textboxes and submit button: <form> x: <input type="text" name="x" /><br /> y: <input type="text" name:"y" /><br /> <input type="submit" value="Submit"/><br /> </form> And i need it so that they change the values of these: //this shows where my sprite will start on the canvas var block_x; var block_y; searched the internet for hours and cant really find anything i understand or works. any help is much appreciated I got an index.php Code: <html> <form action="bacakomik.php" method='post'> <select name="kodekomik"> <option value='../komik1/|23'>Judul Komik1</option> <option value="../komik2/|20">Judul Komik2</option> <option value="../komik3/|10">Juduk Komik3</option> <option value="../komik4/|20">Judul Komik4</option> </select> <input type="submit" /> </form> <?php echo ('<select>'); echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); echo ('</select>'); ?> </html> As you can see, each of the option brings specific value "../komik1/|23" komik1 is a directory | is a delimiter 23 is the pages in one chapter and can be considered also as how many images are there on a specific directory This is my bacakomik.php Code: <?php $dirkomik = $_POST['kodekomik']; $exploded = explode("|", $dirkomik); echo ($exploded[0]); //picture directory echo ("<br>"); echo ($exploded[1]); //total page in the comic $pagecount = (int)$exploded[1]; //Take last posted value, process it right away echo ('<FORM name="guideform"> '); echo ('<select name="guidelinks">'); $i=1; do { echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); $i= $i+1; }while($i <= $pagecount); //Printing option and select echo ("</select>"); ?> <input type="button" name="go" value="Go!" onClick="document.getElementById('im').src=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value+'.png';"> </FORM> <img src="img0.jpg" id="im"> With the current code on bacakomik.php, I only can change the img src of id "im" in the same directory only. What I want is that the Javascript could "add" the "$exploded[0]" variable so that the picture can be loaded from different directory. Anyone can do this? I believe that the fix should be somewhere on input tag inside OnClick, or do you know where? Anyway, I found this on the net http://p2p.wrox.com/php-faqs/11606-q...avascript.html Please help me to those who can... I want to insert this js snippet Code: function addText(smiley) { document.getElementById('message').value += " " + smiley + " "; document.getElementById('message').focus(); return false; } to a loaded iframe with name&id chtifrm. I can access it & change embed something in its html via using something like: Code: $(parent.chtifrm.document.body).append('<div id=\"smly\" style=\"cursor:pointer;float:left;top:200px;display:none;position:absolute;\"><\/div>'); .... Code: parent.chtifrm.document.getElementById('chatbox_option_disco').style.display == 'none' but how do I insert js in the head of loaded iframe? Hi Guys I am trying to modify the functionality of my page. I want to be able to activate this piece of code using another javascript function. This is the code I want to activate: Code: <script type="text/javascript"><!-- $('#button-cart').bind('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, .date_data input[type=\'text\']'), dataType: 'json', success: function(json) { $('.success, .warning, .attention, information, .error').remove(); if (json['error']) { if (json['error']['warning']) { $('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.warning').fadeIn('slow'); } for (i in json['error']) { $('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>'); } } if (json['success']) { $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.success').fadeIn('slow'); $('#cart_total').html(json['total']); $('html, body').animate({ scrollTop: 0 }, 'slow'); } } }); }); //--></script> And this is how I want the format of the function to be: function testsession() { if there is a session called 'hiredate' { activate the script above } else { var el = document.getElementById("product_data"); } } I just dont know how to write this in javascript Could you help me if possible please All -- I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so: <script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js } in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load... $.getScript("gameLibrary.js"); However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem. My options a 1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense. 2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers). jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work. Help appreciated. Nero I wrote a log function that took note of various function calls. Thinking that functions are first class objects, and objects have properties, I made the name of each logged function a property of that function, e.g., brightenInnerPara.name = "brightenInnerPara"; Every browser I tried (Firefox, MSIE, Opera, Chrome, Safari) accepted the assignment, no problem. In Firefox and MSIE, the result was what I wanted: brightenInnerPara.name == "brightenInnerPara" But in the others, the result was: brightenInnerPara.name == null Question 1. Which Javascript is correct here? I favor Firefox and MSIE, not merely because they were willing to give me what I wanted, but also because it makes no sense to accept an assignment statement without throwing an error and then give it a null semantics, like Chrome, Opera, and Safari did. I found a workaround, using assignments like this: brightenInnerPara.prototype.name = "brightenInnerPara"; To my surprise, that worked in every browser. But I don't know why. It seems that such assignments are enough to cause each function to have its own distinct prototype. Question 2. Just how inefficient is my workaround, and why does it work? <HEAD> <script type="text/javascript"> var arrItems1 = new Array(); var arrItemsGrp1 = new Array(); arrItems1[3] = "Truck"; arrItemsGrp1[3] = 1; arrItems1[4] = "Train"; arrItemsGrp1[4] = 1; arrItems1[5] = "Car"; arrItemsGrp1[5] = 1; arrItems1[6] = "Boat"; arrItemsGrp1[6] = 2; arrItems1[7] = "Submarine"; arrItemsGrp1[7] = 2; arrItems1[0] = "Planes"; arrItemsGrp1[0] = 3; arrItems1[1] = "Ultralight"; arrItemsGrp1[1] = 3; arrItems1[2] = "Glider"; arrItemsGrp1[2] = 3; var arrItems2 = new Array(); var arrItemsGrp2 = new Array(); arrItems2[21] = "747"; arrItemsGrp2[21] = 0 arrItems2[22] = "Cessna"; arrItemsGrp2[22] = 0 arrItems2[31] = "Kolb Flyer"; arrItemsGrp2[31] = 1 arrItems2[34] = "Kitfox"; arrItemsGrp2[34] = 1 arrItems2[35] = "Schwietzer Glider"; arrItemsGrp2[35] = 2 arrItems2[99] = "Chevy Malibu"; arrItemsGrp2[99] = 5 arrItems2[100] = "Lincoln LS"; arrItemsGrp2[100] = 5 arrItems2[57] = "BMW Z3"; arrItemsGrp2[57] = 5 arrItems2[101] = "F-150"; arrItemsGrp2[101] = 3 arrItems2[102] = "Tahoe"; arrItemsGrp2[102] = 3 arrItems2[103] = "Freight Train"; arrItemsGrp2[103] = 4 arrItems2[104] = "Passenger Train"; arrItemsGrp2[104] = 4 arrItems2[105] = "Oil Tanker"; arrItemsGrp2[105] = 6 arrItems2[106] = "Fishing Boat"; arrItemsGrp2[106] = 6 arrItems2[200] = "Los Angelas Class"; arrItemsGrp2[200] = 7 arrItems2[201] = "Kilo Class"; arrItemsGrp2[201] = 7 arrItems2[203] = "Seawolf Class"; arrItemsGrp2[203] = 7 var arrItems3 = new Array(); var arrItemsGrp3 = new Array(); arrItems3[300] = "Poola"; arrItemsGrp3[300] = 5 var arrItems4 = new Array(); var arrItemsGrp4 = new Array(); arrItems4[131] = "NANA"; arrItemsGrp4[131] = 6 function selectChange(control, controlToPopulate, ItemArray, GroupArray) { var myEle ; var x ; // Empty the second drop down box of any choices for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null; if (control.name == "firstChoice") { // Empty the third drop down box of any choices for (var q=form.thirdChoice.options.length;q>=0;q--) form.thirdChoice.options[q] = null; } // ADD Default Choice - in case there are no values myEle = document.createElement("option") ; myEle.value = 0 ; myEle.text = "[SELECT]" ; // controlToPopulate.add(myEle) ; controlToPopulate.appendChild(myEle) // Now loop through the array of individual items // Any containing the same child id are added to // the second dropdown box for ( x = 0 ; x < ItemArray.length ; x++ ) { if ( GroupArray[x] == control.value ) { myEle = document.createElement("option") ; //myEle.value = x ; myEle.setAttribute('value',x); // myEle.text = ItemArray[x] ; var txt = document.createTextNode(ItemArray[x]); myEle.appendChild(txt) // controlToPopulate.add(myEle) ; controlToPopulate.appendChild(myEle) } } } function selectChange(control, controlToPopulate, ItemArray, GroupArray) { var myEle ; var x ; // Empty the second drop down box of any choices for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null; if (control.name == "firstChoice") { // Empty the third drop down box of any choices for (var q=form.thirdChoice.options.length;q>=0;q--) form.thirdChoice.options[q] = null; } // ADD Default Choice - in case there are no values myEle=document.createElement("option"); theText=document.createTextNode("[SELECT]"); myEle.appendChild(theText); myEle.setAttribute("value","0"); controlToPopulate.appendChild(myEle); // Now loop through the array of individual items // Any containing the same child id are added to // the second dropdown box for ( x = 0 ; x < ItemArray.length ; x++ ) { if ( GroupArray[x] == control.value ) { myEle = document.createElement("option") ; //myEle.value = x ; myEle.setAttribute("value",x); // myEle.text = ItemArray[x] ; var txt = document.createTextNode(ItemArray[x]); myEle.appendChild(txt) // controlToPopulate.add(myEle) ; controlToPopulate.appendChild(myEle) } } } // --> </script> </HEAD> <BODY> <form name=form> <table align="center"> <tr> <td> <select id="firstChoice" name="firstChoice" onchange="selectChange(this, form.secondChoice, arrItems1, arrItemsGrp1);"> <option value="0" selected>[SELECT]</option> <option value="1">Land</option> <option value="2">Sea</option> <option value="3">Air</option> <option value="4">Coi</option> <option value="5">Nas</option> <option value="6">Ureche</option> </select> </td> </tr> <tr> <td> <select id="secondChoice" name="secondChoice" onchange="selectChange(this, form.thirdChoice, arrItems2, arrItemsGrp2);"> </select> </td> </tr> <tr> <td> <select id="thirdChoice" name="thirdChoice" onchange="selectChange(this, form.fourthChoice, arrItems3, arrItemsGrp3);"> </select> </td> </tr> <tr> <td> <select id="fourthChoice" name="fourthChoice" onchange="selectChange(this, form.fifthChoice, arrItems4, arrItemsGrp4);"> </select> </td> </tr> <tr> <td> <select id="fifthChoice" name="fifthChoice"> </select> </td> </tr> </table> </form> So I've got this script but the 4th column seems to be not working and also I need for the 5th column something special that I don't know how to code I need when for instance : Variable1 from column 1 + variable 2 from column 2 + variable 1 from column 3 + variable 3 from column 4 to result something where that something is a price(house price) ( all columns mean drop down ) I'm trying to make a house calculator and the 1st column that with land sea bla bla will be the house construction type, 2nd column construction phase, 3rd column construction length, 4th construction height of building, and when different values are selected a price should pop-up. I've made one in joforms.com that is online here http://www.verde-green.ro/calculator.htm and had the 4 columns I need but can't set-up conditions to make a price only show up after condition have been done. Please Respond, Regards a Noob Scripter :| I have one jsp popup window. In that popup window i have 5 tabs. each tab have different functionality. the bottom of the popup window two button i have. one is "save" and another one is "save&close". By default 1st tab will showup in my popup window. When i click other tabs "save" and "save&Close" buttons will show up commonly. I recently implemented one logic if i do some modifications in this popup window with first tab after i click on "save" button one small popup window should open. which is working fine. my problem is : that popup should open only if i do modification under 1st tab. but the popup opens remaining tab modifications also when i do click on "save" button. How do i stop that popup if i do modifications in remaining tabs other than first tab ?? |