JavaScript - Increase/decrease Size Of Div Using Buttons
I wish to increase or decrease the size of a div by using + and - buttons
how would this be done Similar TutorialsHi 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?.. 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 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. I have an iframe that is a specific height and width. I want to detect whenever the the iframe is no longer exactly the height i set it to. If a user has CSS turned off for example the iframe will be in default height and width. I want to detect that. This is how you'd normally do it but this only returns the original size (try with 'no style' in Firefox): Code: function getSize() { alert('height is now '+document.getElementById("Iframemain").height) alert('height is now '+document.getElementById("Iframemain").width) } Is it possible? hello, I created this program to hold 5 cd's and some information relating to them. I keep getting an error that says: cannot find symbol symbol : class ButtonListener location: class inventoryprogram.InventoryProgram ActionListener btnListen = new ButtonListener(); // create listener here is the part of code with the actionlistener in it [CODE] private JPanel createButtonPanel() { // begin method createButtonpanel method ActionListener btnListen = new ButtonListener(); // create listener // create button objects JButton nextButton = new JButton("Display Cd"); // create and label button nextButton.setActionCommand("Next"); // action command for click nextButton.addActionListener(btnListen); nextButton.addActionListener(this); JPanel panel = new JPanel(); panel.add(nextButton); // add next button to panel return panel; // return panel } // end method createButtonPanel [ICODE] Hi all, I'm having trouble getting the following right: Code: <IMG border="0" onMouseOver=this.src="home2.gif" onMouseOut=this.src="home.gif" onClick=this.src="home2.gif" SRC="home.gif"> The idea is that after somebody clicks it, the button will remain home2.gif, but ofcourse if u mouseout after the click it will return to home.gif. Can somebody please help me with this problem?! I'm not really good at js, so I've been struggling with this for quite a few days ! Thnx alot! Sjaroow I've been looking around and all the validation stuff I've seen doesn't work for what I have. Here is what I am trying to do: The user selects the Heads or Tails radio button for the first flip and then selects heads or tails radio button for the 2nd flip. The script then randomly flips two coins and compares it to what the user selected and if they are the same the user wins and if not then they lose. So there would be 4 buttons total, two Heads and two Tails. The first set of Heads and Tails needs to be assigned to "guess1" and the 2nd set is "guess2". So if the user clicks Tails for Flip1 and Heads for Flip2 then Tails is assigned to guess1 and Heads is assigned to guess2. Right now the script just assumes the user is selecting heads for both flips. Code: <html> <head> <title>Guess Two Coin Tosses</title> <script> function flip5(){ //Input var guess1 = document.getElementById('guess1').value var guess2 = document.getElementById('guess2').value var flip1 = Math.floor(Math.random() * 2) var flip2 = Math.floor(Math.random() * 2) var outcomes if (flip1 == 0) flip1 = 'Heads'; else flip1 = 'Tails'; if (flip2 == 0) flip2 = 'Heads'; else flip2 = 'Tails'; //Processing if (flip1.toUpperCase() == guess1.toUpperCase()) { if (flip2.toUpperCase() == guess2.toUpperCase()) outcomes = 'win win'; else outcomes = 'win lose'; } else { // here we lost the first if (flip2.toUpperCase() == guess2.toUpperCase()) outcomes = 'lose win'; else outcomes = 'lose lose'; } //Output document.getElementById('flip1').value = flip1 document.getElementById('flip2').value = flip2 document.getElementById('outcomes').value = outcomes } </script> </head> <body> <h3>Predict the Futu Guess Two Coin Flips</h3> Enter Heads for Heads, Tails for Tails! Case does not matter! <p/>Your Guess for Flip-1: <input type=radio id="guess1" size="5" value="Heads" />Heads <input type=radio id="guess1" size="5" value="Tails" />Tails <p/>Your Guess for Flip-2: <input type=radio id="guess2" size="5" value="Heads" />Heads <input type=radio id="guess2" size="5" value="Tails" />Tails <p/>Flip-1: <input type="text" id="flip1" size="5" value="???" /> <p/>Flip-2: <input type="text" id="flip2" size="5" value="???" /> <p/><input type="button" value="Flip Two!" onclick="flip5()" /> <p/>Outcomes: <input type="text" id="outcomes" size="20" value="" /> <hr> </body> </html> I have a page where I have a image displayed and 3 buttons underneath the image. The image displayed is the outdoor tool "hoe". I have the buttons named saw, hoe and tree trimmer below the image. What I want to do is when the user of the web page clicks a button, let's say for example tree trimmer the new image will appear on the page in place of the old image. Right now my code is messed up, it does not matter what image you click but only a image of a saw appears. Also I cannot get my image centered correctly. Does anyone have any suggestions to help me? <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <style type="text/css"> img.shown {display: block; margin-left: auto; margin-right: auto; } </style> </head> <h1 style="text-align:center">A simple slide show</h1> <script> function pictureChange() { document.getElementById("shown").src="/tools/saw.jpg"; } </script> <body> <img id="shown" src="/tools/hoe.jpg";> <p><input type="button" id="theButton" value="Saw" onclick="pictureChange()"> </p> <p><input type="button" id="theButton" value="Hoe" onclick="pictureChange()"> </p> <p><input type="button" id="theButton" value="Tree Trimmer" onclick="pictureChange()"> </p> </body> </html> *** I have tried this code snipet below and it does not work for me because I don't know the actual url, the images are uploaded to a server.*********** function pictureChange(imgurl) { document.getElementById("shown").src='/tools/' + imgurl + '.jpg'; } i have a simple frame that looks like this http://i307.photobucket.com/albums/n...aker/help2.jpg i have 3 pages (side.html, page1.html and page2.html) the above picture has side.html and page1.html loaded on default, what i want to do is whenever i click on the page 1 button, page1.html will load on the right side and when i click on page 2 button, page2.html will load i cant figure out what the code for this is and googling for the solution isn't getting me anywhere help please Hi, I have buttons like these: PHP Code: <button type="button" onclick="izdas()">Iždas</button> <button type="button" onclick="miestas()">Miestas</button> <button type="button" onclick="map()">Žemėlapis</button> <button type="button" onclick="infantry()">Kariuomenė</button> <button type="button" onclick="biuld()">Statiniai</button> How I can add images on them?? Size would be 100x20px. Also, I would e thankful if someone would help me position them in one vertical line. Thanks in advance... On my website I have a radio button as any other normal radio button. <input type="radio" name="crime" value="4" id="4" class="submit"> is there any way to get rid of this radio button and click something for example <tr> <td>Blah blah</td> <td>Blah Blah</td> </tr> is there any code i can put in the <tr> tag so if i click that section it will act as a radio button and when its selected change the background of the tr section. On my website I have a radio button as any other normal radio button. <input type="radio" name="crime" value="4" id="4" class="submit"> is there any way to get rid of this radio button and click something for example <tr> <td>Blah blah</td> <td>Blah Blah</td> </tr> is there any code i can put in the <tr> tag so if i click that section it will act as a radio button and when its selected change the background of the tr section. Im trying to configuere a form that a. a radio buttons that allow the user to choose between quarters, nickels, dimes and pennies. and show image when click on my radio button im confused on how to get the image to display whenthey click on the radio button On custom button images, how do you give them the effect that they're "pushed" when the user clicks them and "unpushed" when the user lets his finger off the mouse button? I'm guessing it's some type of rollover effect, but I'm not sure how it's done.
hello, this is my first attempt in javascript. im trying to make custom radio buttons here is the code i have: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <style type="text/css"> .hide {display:none;} .radio {width:16px;height:16px;} </style> <script type="text/javascript"> // declare variables or different states var off = 'images/check-off.png'; var on = 'images/check-on.png'; var radioImage = document.createElement('img'); function replaceRadios(){ var radios = document.getElementsByName('radio1'); radios.type = 'radio' for (r = 1; r < radios.length; r++) { // if radio is checked configure the img src to var on if (radios[r].type = 'radio' && radios[r].checked) { radioImage.src = on; radioImage.className= 'radio on'; } else { // otherwise configure the img src to var normal/off and give it a class of radio radioImage.src = off; radioImage.className= 'radio off'; } // give the image an id of radio radioImage.className = 'radio'; radioImage.onclick= radioStates; radios[r].parentNode.insertBefore(radioImage,radios[r]); // hide the radio button to show image radios[r].className = 'hide'; } } function radioStates(r) { var radios = document.getElementsByName('radio1'); if (radios.checked = true) { radioImage.setAttribute("class", "radio on"); radioImage.src = on; } else if (radios.checked = false) { radioImage.setAttribute("class", "radio off"); radioImage.src = off; } else { radioImage.setAttribute("class", "radio off"); radioImage.src = off; } } setTimeout("replaceRadios()", 0); </script> </head> <body> <form name="radiotest"> <input type="radio" id="radio1" class="radio" name="radio1" /> <input type="radio" id="radio2" class="radio" name="radio1" /> <input type="submit" id="submit" name="submit" /> </form> </body> </html> If anyone could help me, I would greatly appreciate it. Hello. I am a new user. I have got a website, www.eastbourneinks.co.uk where the quantity buttons (+) & (-) do not work on most computers where I have had feedback. Is there any way of making them work on any/all computers. This is one of the pages: http://eastbourneinks.co.uk/product/...nk-cartridges/ Many thanks. Phil. There has to be a way to do what I want to do but I'm fugged iif I know how. Here's the problem... A page has three frames - top, left and disp. Top and left contain a number of buttons that display another page in disp. All the buttons need to behave as one set of radio buttons; when a button is clicked any other button returns to the non-clicked state. The really awkward bit is there's an image in top that changes depending on the currently clicked button and that image is behind the buttons. Here it is in pseudocode of sorts. Code: On click button[n] Button[LastClicked].Image := Button[LastClicked].UnClickedImage; Button[n].Image := Button[n].ClickedImage; Top.Image := Button[n].TopImage; end; I hope that makes sense. If some kind soul has any idea of how to do that I'd be very grateful. Thanks. Simon. I'm having trouble with a 3-state rollover with rollClick staying active for a series of buttons. Each button reveals it's own content within the same page. Here's a working example of what I have. The roll in and out works fine at first, but after the second click the images start getting jumbled together. Something to do with the lastClick code at the bottom I think. HTML-side my button images get class="rollover" and a unique id. Code: window.onload = rolloverInit; document.getElementsByClassName = function(cl) { var retnode = []; var myclass = new RegExp('\\b'+cl+'\\b'); var elem = this.getElementsByTagName('*'); for (var i = 0; i < elem.length; i++) { var classes = elem[i].className; if (myclass.test(classes)) retnode.push(elem[i]); } return retnode; }; function rolloverInit(){ var rollOvers = document.getElementsByClassName("rollover"); for(var i=0; i<rollOvers.length; i++){ setupRollover(rollOvers[i]); } } function setupRollover(thisImage){ //UP thisImage.outImage = new Image(); thisImage.outImage.src = "images/" + thisImage.id + "1.gif"; thisImage.onerror = thisImage; thisImage.onmouseout = rollOut; //OVER thisImage.clickImage = new Image(); thisImage.clickImage.src = "images/" + thisImage.id + "2.gif"; thisImage.onerror = rollOut; thisImage.onmousedown = rollClick; //DOWN thisImage.overImage = new Image(); thisImage.overImage.src = "images/" + thisImage.id+"2.gif"; thisImage.onerror = rollOut; thisImage.onmouseover = rollOver; thisImage.onmouseup = rollOver; } function rollOver() { this.src = this.overImage.src; } function rollOut() { this.src = this.outImage.src; } function rollClick() { if(lastClick){ lastClick.onmouseout = rollOut; lastClick.src = this.outImage.src; } this.src = this.clickImage.src; this.onmouseout = rollClick; lastClick = this; } var lastClick = null; What I'd also like, since these buttons act as tabs, is for the first button to already be in the rollClick active state on page load (since that button's content is already displayed by default). Is this possible? Thanks for any help you can provide! Hello there, Can some one gimme source code for greying out a button on php page. In my application i have one play button and one stop button in the html form. If i click play button it will update database with play and invoke a script. similarly with stop. so while they are being played i want this play button to be greyed out. or is there any way that i can only show stop button while playing and play button while not playing the files. HELP PLZZZZZZZZ hello, Im trying to write a program when the user clicks on the button, the textbox should display "how are you ". This is what I tried : <html> <head> <title>"Click"</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p> <input name="text1" type="text" id="text1" value="textbox 1" onFocus="this.style.background ='yellow'" onBlur="this.style.background='white'"> </p> <p> <input name="text2" type="text" id="text2" value="textbox 2" onFocus="this.style.background = 'yellow'" onBlur="this.style.background='white'"> </p> <p> <button onclick="textbox1.value="how are you">Click Me!</button> </p> </body> </html> |