JavaScript - Changing Div Height
Can DIV located in the MasterPage be resized depending on the screen resolution?
<tr style="vertical-align: top;"><td> <div id="mainArea"> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server" /> </div></td></tr> I've tried unsuccessfully - var height = screen.height; var area1 = document.getElementById('ctl00_mainArea'); if (height == 1024) { area1.setAttribute("height", "700px"); } else if (height == 864) { area1.setAttribute("height", "540px"); } Also tried area1.style.height = 700 + "px"; (no luck as well) Similar TutorialsHi, I need to re-size a div to be 100% of the browser but taking into account the height of an existing header div. Currently it works but it doesn't factor the height of the above header div, and therefore scrolls off the page (the height of the header div) I need to manipulate ( subtract the height value of the header) in the javascript somehow. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript"> function SetHeightOfDiv(){ var theDiv = document.getElementById('content'); theDiv.style.height = BrowserHeight()+"px"; } function BrowserHeight() { var theHeight; if (window.innerHeight) { theHeight = window.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { theHeight = document.documentElement.clientHeight; } else if (document.body) { theHeight = document.body.clientHeight; } return theHeight; } </script> </head> <body style="height:100%; background-color:blue; margin:0; padding:0; color:#ffffff; font-size:15px; text-align:center; font-family:monospace,arial" onload="SetHeightOfDiv()"> <div id="wrapper" style="height:100%; width:900px; background-color:yellow; margin-left:auto; margin-right:auto; overflow:hidden"> <div id="header" style="margin-top:0px; height:130px; width:890px; margin-left:5px; background-color:red; position:fixed"> <p>The FIXED HEADER</p> </div> <div id="content" style="margin-top:132px; background-color:grey; width:890px; margin-left:5px"> <p>THE BODY - that extends below the browser window (possibly the height of the header)</p></br> <p>So how do we manipulate the Javascript to 'Subtract' the height of the HEADER?</p></br> <p style="text-align:left; padding-left:10px"> function SetHeightOfDiv(){ <br> var theDiv = document.getElementById('content');<br> theDiv.style.height = BrowserHeight()+"px";<br> }<br> </br> function BrowserHeight() {<br> var theHeight;<br> if (window.innerHeight) {<br> theHeight = window.innerHeight;<br> }<br> else if (document.documentElement && document.documentElement.clientHeight) {<br> theHeight = document.documentElement.clientHeight;<br> }<br> else if (document.body) {<br> theHeight = document.body.clientHeight;<br> }<br> return theHeight;<br> }</p> </div> </div> <!--end of wrapper--> </body> </html> Thanks I have this script where people can pick a price and pick quataty. i want it to be only one price and let the person input quatity them selves, how can this be done? Thanks in advance Code: <script type="text/javascript"> function calculate_amount() { var subtotal = 0; var hamburger_subtotal = 0; var hamburger = document.myform.hamburger.value; var hamburger_qty = document.myform.hamburger_qty.value; var cheeseburger_subtotal = 0; var cheeseburger = document.myform.cheeseburger.value; var cheeseburger_qty = document.myform.cheeseburger_qty.value; var pst = 0; var gst = 0; var total = 0; //etc... //var chicken_burger; //var fries; //var gravy; //var chili; if (hamburger > 0) { hamburger_subtotal = hamburger * hamburger_qty; } subtotal = hamburger_subtotal; // myform -- depends on the name of your actual form, if it does not have one give it one. document.myform.display_hamburger_subtotal.value = hamburger_subtotal; if (cheeseburger > 0) { cheeseburger_subtotal = cheeseburger * cheeseburger_qty; } // myform -- depends on the name of your actual form, if it does not have one give it one. document.myform.display_cheeseburger_subtotal.value = cheeseburger_subtotal; subtotal = subtotal + cheeseburger_subtotal; pst = .07 * subtotal; gst = .05 * subtotal; // you cannot add the values after you call toFixed, so do the total now! total = subtotal + pst + gst; total = total.toFixed(2); subtotal = subtotal.toFixed(2); pst = pst.toFixed(2); gst = gst.toFixed(2); // this is wrong var tax = foo * 1.07; document.myform.display_subtotal.value = subtotal; document.myform.display_pst.value = pst; document.myform.display_gst.value = gst; //total = subtotal += pst += gst; document.myform.display_total.value = total; } </script> // first off this all needs to be wrapped in form tags if you are going to post the values to something. // you need to look up how to name your items, you should have an input type=x with name=y and id=y <form name="myform"> <table width="325"> <tbody> <tr> <th width="144">item</th> <th width="75">price</th> <th width="92">quantity</th> <th width="101">sub-total</th> </tr> <tr align="middle"> <td align="left">Hamberger</td> <td><select id="hamburger" name="hamburger" onchange="calculate_amount()"> <OPTION VALUE='2.99'>2.99</OPTION> <OPTION VALUE='3.99'>$.99</OPTION> <OPTION VALUE='4.99'>4.99</OPTION> </select> </td> <td><select id="hamburger_qty" name="hamburger_qty" onchange="calculate_amount()"> <OPTION VALUE='0'>0</OPTION> <OPTION VALUE='1'>1</OPTION> <OPTION VALUE='2'>2</OPTION> <OPTION VALUE='3'>3</OPTION> <OPTION VALUE='4'>4</OPTION> <OPTION VALUE='5'>5</OPTION> <OPTION VALUE='6'>6</OPTION> <OPTION VALUE='7'>7</OPTION> <OPTION VALUE='8'>8</OPTION> <OPTION VALUE='9'>9</OPTION> </select> </td> <td><input type="text" id="display_hamburger_subtotal" name="display_hamburger_subtotal" size="10" disabled="disabled" /></td> </tr> <td align="left">Cheeseberger</td> <td><select id="cheeseburger" name="cheeseburger" onchange="calculate_amount()"> <OPTION VALUE='3.99'>3.99</OPTION> <OPTION VALUE='4.99'>4.99</OPTION> <OPTION VALUE='5.99'>5.99</OPTION> </select> </td> <td><select id="cheeseburger_qty" name="cheeseburger_qty" onchange="calculate_amount()"> <OPTION VALUE='0'>0</OPTION> <OPTION VALUE='1'>1</OPTION> <OPTION VALUE='2'>2</OPTION> <OPTION VALUE='3'>3</OPTION> <OPTION VALUE='4'>4</OPTION> <OPTION VALUE='5'>5</OPTION> <OPTION VALUE='6'>6</OPTION> <OPTION VALUE='7'>7</OPTION> <OPTION VALUE='8'>8</OPTION> <OPTION VALUE='9'>9</OPTION> </select> </td> <td><input type="text" id="display_cheeseburger_subtotal" name="display_cheeseburger_subtotal" size="10" disabled="disabled" /></td> </tr> <tr align="middle"> <td align="left">Chicken Burger</td> <td><input size="7" value="$4.99" /></td> <td><input size="3" /></td> <td><input size="10" /></td> </tr> </tbody> </table> <table width="324"> <tbody> <tr> <th width="124">item</th> <th width="42">price</th> <th width="72">quantity</th> <th width="74">sub-total</th> </tr> <tr align="middle"> <td align="left">French Fries</td> <td><input size="7" value="$2.99" /></td> <td><input size="3" /></td> <td><input size="10" /></td> </tr> <tr align="middle"> <td align="left"><input type="checkbox" /> gravy</td> <td><input size="7" value="$0.50" /></td> <td><input size="3" /></td> <td><input size="10" /></td> </tr> <tr align="middle"> <td align="left"><input type="checkbox" /> chilli</td> <td><input size="7" value="$1.99" /></td> <td><input size="3" /></td> <td><input size="10" /></td> </tr> </tbody> </table> <table align="right"> <tbody> <tr> <td>subtotal</td> <td><input type="text" id="display_subtotal" name="display_subtotal" size="10" disabled="disabled" /></td> </tr> <tr> <td>pst 7%</td> <td><input type="text" id="display_pst" name="display_pst" size="10" disabled="disabled" /></td> </tr> <tr> <td>gst 5%</td> <td><input type="text" id="display_gst" name="display_gst" size="10" disabled="disabled" /></td> </tr> <tr> <td>total</td> <td><input type="text" id="display_total" name="display_total" size="10" disabled="disabled" /></td> </tr> <tr> <td colspan="2"><input type="button" value="total up order" /> </td> </tr> </tbody> </table> </form> Code: <img src = "/images/boats/large/my-red-pepper---8019812411a.jpg" width = "690" height = "350" id = "main_image" /> <div id = "gallery_thumbs"> <img src = "/images/nav_left.png" alt = "Back" id = "nav_back" /> <div id = "inner_thumbs"> <div style="width:10000px" id="sliding_thumbs"> <a href = "/images/boats/large/my-red-pepper---8019812411a.jpg" onclick = "document.getElementById('main_image').src=this.href;return false;" ><img src = "/images/boats/gallery_thumbs/my-red-pepper---8019812411a.jpg" /></a> <a href = "/images/boats/large/my-red-pepper---8019812411a.jpg" onclick = "document.getElementById('main_image').src=this.href;return false;" ><img src = "/images/boats/gallery_thumbs/my-red-pepper---8019712411a.jpg" /></a> <a href = "/images/boats/large/my-red-pepper---8019812411a.jpg" onclick = "document.getElementById('main_image').src=this.href;return false;" ><img src = "/images/boats/gallery_thumbs/my-red-pepper---8019412411a.jpg" /></a> <a href = "/images/boats/large/my-red-pepper---8019812411a.jpg" onclick = "document.getElementById('main_image').src=this.href;return false;" ><img src = "/images/boats/gallery_thumbs/my-red-pepper---8019312411a.jpg" /></a> <a href = "/images/boats/large/my-red-pepper---8019812411a.jpg" onclick = "document.getElementById('main_image').src=this.href;return false;" ><img src = "/images/boats/gallery_thumbs/my-red-pepper---8019212411a.jpg" /></a> <a href = "/images/boats/large/my-red-pepper---8019812411a.jpg" onclick = "document.getElementById('main_image').src=this.href;return false;" ><img src = "/images/boats/gallery_thumbs/my-red-pepper---8019512411a.jpg" /></a> <a href = "/images/boats/large/my-red-pepper---8019812411a.jpg" onclick = "document.getElementById('main_image').src=this.href;return false;" ><img src = "/images/boats/gallery_thumbs/my-red-pepper---8019612411a.jpg" /></a> <a href = "/images/boats/large/my-red-pepper---8019812411a.jpg" onclick = "document.getElementById('main_image').src=this.href;return false;" ><img src = "/images/boats/gallery_thumbs/big_my-red-pepper---12411-main.jpg" /></a> </div> </div> Why isn't this working? document.getElementById('main_image').src=this.href;return false; I originally had this: Code: $('#sliding_thumbs a').click(function() { $('#main_image').attr('src',this.href); return false; }) but that didn't work so I put the onclick inline and it still isn't working but I can't fathom why. I have confirmed that the #main_image is being detected correctly (by alerting the src) and that the this.href part contains the url of an image but nothing happens. There is no error and the large image doesn't load in the same window (so the return false part is working!) If you wanted to change an ids onclick would int you just do this document.getElementById("").onclick = ""; Is there a way to do it? I go to a page and have this in the URL http://beta.pigskinempire.com/boxscore.asp?w=6&s=5&yr= I want to create a link on that page that when you click it it changes the URL to http://beta.pigskinempire.com/game.asp?gnum=6&gslot=5 as you can see the numbers 6 and 5 are about the only things that are similar in the substring. I will have this on multiple pages so it will be taking different numbers from the same spots of the URL and plugging them into the new URL into the correct location. Thank you very much if you can help me, I am thinking regEx will be needed but I am not very comfortable with it. Thanks again. Hey all, for some reason, I can't get the margin-top property to change using Code: jQ(this.centerPiece).attr('marginTop', this.imgSrcs[ this.srcs[5] ].top); also tried jQ(this.centerPiece).attr('margin-top', this.imgSrcs[ this.srcs[5] ].top); any help would be great townsendwebdd.com is the site Code: /**Scroller*/ function Scroller(){ //grab the img elements //this.imgs = new Array( '#img0', '#img1', '#img2', '#img3', '#img4', '#centerImg', '#img5', '#img6', '#img7', '#img8', '#img9' ); this.imgs = new Array( '#img0', '#img1', '#img2', '#img3', '#centerImg', '#img6', '#img7', '#img8', '#img9' ); this.centerPiece = '#centerImg'; this.centerPieceLink = '#centerA'; //set the image locations this.imgSrcs = new Array(); this.imgSrcs.push(new imgSrc('gx/tiltedNMInvestigates.png', 'gx/tiltedNMInvestigatesRight.png', 'gx/nmInvestigates.jpg', 'http://nminvestigates.townsendwebdd.com', 100 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedChess.png', 'gx/tiltedChessRight.png', 'gx/chess.jpg', 'http://townsendwebdd.com/chess', 200 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedFiveInARow.png', 'gx/tiltedFiveInARowRight.png', 'gx/fiveInARow.jpg', 'http://fiveinarow.townsendwebdd.com', 0 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedGaelsong.png', 'gx/tiltedGaelsongRight.png', 'gx/gaelsong.jpg', 'http://gaelsong.townsendwebdd.com', 100 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedGreenBay.png', 'gx/tiltedGreenBayRight.png', 'gx/greenBay.jpg', 'http://townsendwebdd.com/gx/GreenBaySite.jpg', 0 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedMillarSmith.png', 'gx/tiltedMillarSmithRight.png', 'gx/millarSmith.jpg', 'http://townsendwebdd.com/gx/millarSmith.jpg', 100 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedNanoMeds.png', 'gx/tiltedNanoMedsRight.png', 'gx/nanomeds.jpg', 'http://townsendwebdd.com/gx/nuBots2.jpg', 0 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedAlegro.png', 'gx/tiltedAlegroRight.png', 'gx/alegro.jpg', 'http://townsendwebdd.com/gx/alegro2.jpg', 300 ) ); this.imgSrcs.push(new imgSrc('gx/tiltedApnm.png', 'gx/tiltedApnmRight.png', 'gx/apnm.jpg', 'http://townsendwebdd.com/gx/apnm.jpg', 0 ) ); //this.imgSrcs.push(new imgSrc('gx/tiltedNanoMeds.png', 'gx/tiltedNanoMedsRight.png', 'gx/nanomeds.jpg', 'http://townsendwebdd.com/gx/nuBots2.jpg') ); //this.imgSrcs.push(new imgSrc('gx/tiltedNMInvestigates.png', 'gx/tiltedNMInvestigatesRight.png', 'gx/nmInvestigates.jpg', 'http://nminvestigates.townsendwebdd.com') ); //which srcs are currently in use this.srcs = new Array(); for(var i = 0; i < this.imgSrcs.length; i++){ this.srcs.push(i); } } /** reset the current images*/ Scroller.prototype.populate = function(){ //populate imgs for(var i = 0; i < 4; i++){ jQ( this.imgs[i] ).attr('src', this.imgSrcs[ this.srcs[i] ].left ); jQ( this.imgs[i + 5] ).attr('src', this.imgSrcs[ this.srcs[i + 5] ].right); } //set the centerPiece jQ(this.centerPiece).attr('src', this.imgSrcs[ this.srcs[i] ].center); jQ(this.centerPieceLink).attr('href', this.imgSrcs[ this.srcs[i] ].href); jQ(this.centerPiece).attr('marginTop', this.imgSrcs[ this.srcs[i] ].top); } /** move everything to the Left*/ Scroller.prototype.moveLeft = function(){ //increment srcs this.incrementSrcsUp(); //animate for(var i = 0; i < this.imgs.length; i++){ if(this.imgs[i] != this.centerPiece) animate(this.imgs[i], -30); } //set the centerPiece jQ(this.centerPiece).attr('src', this.imgSrcs[ this.srcs[5] ].center); jQ(this.centerPieceLink).attr('href', this.imgSrcs[ this.srcs[5] ].href); jQ(this.centerPiece).attr('marginTop', this.imgSrcs[ this.srcs[5] ].top);/** here is the stumper*/ //move back for(i = 0; i < this.imgs.length; i++){ if(this.imgs[i] != this.centerPiece) move( this.imgs[i], 30); } //repopulate this.populate(); } /** move everything to the right*/ Scroller.prototype.moveRight = function(){ //increment srcs this.incrementSrcsDown(); //animate for(var i = 0; i < this.imgs.length; i++){ if(this.imgs[i] != this.centerPiece) animate(this.imgs[i], 30); } //set the centerPiece jQ(this.centerPiece).attr('src', this.imgSrcs[ this.srcs[5] ].center); jQ(this.centerPieceLink).attr('href', this.imgSrcs[ this.srcs[5] ].href); jQ(this.centerPiece).attr('marginTop', this.imgSrcs[ this.srcs[5] ].top);/** here is the stumper*/ //move back for(i = 0; i < this.imgs.length; i++){ if(this.imgs[i] != this.centerPiece) move( this.imgs[i], -30); } //repopulate this.populate(); } Scroller.prototype.incrementSrcsUp = function(){ for(var i = 0; i < this.srcs.length; i++){ this.srcs[i] += 1; if(this.srcs[i] >= this.srcs.length) this.srcs[i] = 0; } } Scroller.prototype.incrementSrcsDown = function(){ for(var i = 0; i < this.srcs.length; i++){ this.srcs[i] -= 1; if(this.srcs[i] < 0) this.srcs[i] = this.imgSrcs.length - 1; } } Scroller.prototype.preload = function(){ try{ for(var i = 0; i < this.imgSrcs.length; i++){ jQ('#container').append("<img src='" + this.imgSrcs[i].center + "' style='display:none;'/>"); } }catch(err){alert(err.message);} } /**the sources of the piece*/ function imgSrc(leftSrc, rightSrc, centerImg, location, topped){ this.left = leftSrc; this.right = rightSrc; this.center = centerImg; this.href = location; this.top = topped; } function animate(imgId, offsetX){ var x = jQ( imgId ).offset().left; var y = jQ( imgId ).offset().top; jQ( imgId ).offset({left: x + offsetX, top: y}); } /** function animate(imgId, offsetX){ var startLeft; var timer = setInterval(function() { imgId.style.left = ( imgId.style.left + offsetX / 10 ) + "px"; if ( imgId.style.left == startLeft + offsetX ) { clearInterval( timer ); } }, 1000); }*/ function move(imgId, offsetX){ var x = jQ( imgId ).offset().left; var y = jQ( imgId ).offset().top; jQ( imgId ).offset({left: x + offsetX, top: y}); } Hi I am opening a child window with the following href. If it is a completly new window, it is opened and the focus shifts to it, ... but ... if that href has been clicked on before and the window exists, the focus stays with the parent window and does NOT shift to the child How can I make the focus shift ? here is my href: PHP Code: echo "<a href='$Ad_detail' rel=\"external\" onclick=\"window.open (this.href, '$Ad_detail', 'height=800,width=960,scrollbars'); return false\" > I guess I need a "window. ??? focus();" in there somewhere - but I don't know what the ??? should be. If you can help - many thanks I've got this script that spins an image for me but it dont stop spinning, in other words when i press startspinning with onclick it dont change it to stopspinning function it just keeps spinning, it works fine with href but not onclick. Code: function StartSpinning() { int = setInterval( 'SpinChange()', 100 ); $( 'SpinButton' ).innerHTML = "Spinning (Click to Stop)"; $( 'SpinButton' ).onclick = "StopSpinning();"; Effect.Fade( 'turns', {duration: 0.3} ); } function StopSpinning() { clearInterval( int ); $( 'SpinButton' ).innerHTML = "Spin it"; $( 'SpinButton' ).onclick = "StartSpinning();"; UpdateFigure(); Effect.Appear( 'turns', {duration: 0.3} ); } Can anyone help thanks. I would like to have a code on my page that causes two or more photos to change between each other. For example, photo 1 is shown for a little while, then it switches to photo 2, etc. I would also like to switch text that goes along with the photos. I would like my layout to look like this: Photo / Text about Photo and have both switch after a little while, to the next photo and text. Hope this makes sense. Thanks in advance! ok i have a script which will make a copy of the html in a div and place it into another div the problem with this it creates a duplicate element with the same id so what i want to know is can i create a new id based off old ids using a generic type script Code: function scope(e) { var popin = document.getElementById('popin'); popin.innerHTML = "<div class='container'>"+e.innerHTML+"</div>"; popin.style.display = "block"; } this code is designed for taking content in a small div and placing it into a larger div to increase the viewing area so what i would need is sumthing that can look for Code: id="sum text" and maybe amend it to Code: id="sum textP" or sumthing to that extent if sum1 could point me in the right direction that would be great if my post is not clear enough just ask me to be more specific or sumthing and i will see what i can do to try and make it more clear if needed How can i edit the following html/javascript so that when a user submits the form the element with id #container is updated with the value from #name <form action="" method="post" name="form_name" id="form_name" onsubmit="return update_name(this)"> <fieldset> <label for="your_name">Enter Your Name</label> <input type="text" name="your_name" id="your_name" /> <input type="submit" /> </fieldset> </form> Ok so i'm trying to write a Greasemonkey script to change all the hrefs on a single page. The href by default looks like this: Code: <a href="javascript:get('246154895')" class="postid">ID</a> What i'm trying to do is make the number from get() appear in stead of "ID". How should i get this done? I started up with this: Code: var posts = document.getElementsByClassname('postid'); for (i=0; i<posts.length; i++) { //Replacing } But i doubt it will work, since there are other items with the class "postid" that aren't related to these tags i'm trying to change. P.S. I'm new to JS so yeah :P I'm working at masking my fantasy football site hosted by my provider onto my own subdomain, since they can't allow me point a dns at their servers. I did manage to mask the webaddress to my sub doman with a php script. But it also only masks the initial visit, and th link name. And now i'm trying to learn how mask the various url/links in the menus. As I little about javascript, can someone show me a way to mask the url address when a user mouses over them? The links themselves wont' change, I'm just trying to mask the link names on the mouseover to look like their on my own domain. Hope that all made some sense hi all, when key pressed, in IE i can use this code: event.keyCode=somenumber; and it works. Is this possible in Netscape - Firefox - ..... ? I need to controll the input, I want to allow users to use only keys I want them to use. Thanks Right then! I have a drop down list. The titles are really long. What I want to happen is, end user to click on a selection, i.e. "This is a really really long title" And then by the power of voodoo just the abbreviated is shown in the field. "TIARRLT" Can this be done by JUST HTML? Or am I looking at some JS here? If anyone could point me to a tutorial that would be great. Or if you have the code you don't mind sharing... amazing!!! Thanks all! Hello guys I have a questions: How can I use javascript to change the CSS the page uses? I'm a noob to javascript so please help me out =D Regards, Thunderofnl I have my code set up so whenever I hover over a picture it changes the background image and I want it so that when I leave the picture the background changes back to a black background but the background just stays as the image. I cant find out why its not changing back when I leave, it looks like everything should work. Code: var bgImage = new Array() bgImage[0] = "url(../Pictures/RM/Iker.jpg)"; bgImage[1] = "url(../Pictures/RM/Arbeloa.jpg)"; parseInt(event.clientX) - parseInt(movingDiv.style.left) function into(whoseCalling) { num =(document.getElementById(whoseCalling).id).substr(3); document.getElementById(whoseCalling).style.borderStyle = "double"; document.getElementById(whoseCalling).style.borderTopColor = "blue"; document.getElementById(whoseCalling).style.borderBottomColor = "red"; document.getElementById(whoseCalling).style.borderLeftColor = "yellow"; document.getElementById(whoseCalling).style.borderRightColor = "green"; document.getElementById(whoseCalling).style.borderWidth = "8px"; for (i=0; i<30; i++) { document.getElementById("img" + i).style.opacity = ".1"; } document.getElementById(whoseCalling).style.opacity = "1"; document.body.style.backgroundImage = bgImage[num] } function out(whoseCalling) { document.getElementById(whoseCalling).style.borderStyle = "solid"; document.getElementById(whoseCalling).style.borderColor = "red"; document.getElementById(whoseCalling).style.borderWidth = "3px"; document.body.style.backgroundColor = "black"; for (i=0; i<30; i++) { document.getElementById("img" + i).style.opacity = "1"; } } Okay, I have this code, Code: <script type="text/javascript"> function changeText2(){ var userInput = document.getElementById('userInput').value; document.getElementById('boldStuff2').innerHTML = userInput; } </script> <p>Welcome to the site <b id='boldStuff2'>dude</b> </p> <input type='text' id='userInput' value='Enter Text Here' /> <input type='button' onclick='changeText2()' value='Change Text'/> A fairly simple one, and it is great, but I want to change it so that the text you type in stays there! Forever! For example, a person visits the site and types in "Hello" then the option of changing the text again disappears, and every visitor after that sees "Hello" (or whatever the first person types). Is this possible? Can anyone help me out! I'm used to other languages so forgive me for this dumb question. I have a double array of divs and I want to change the background color of a div. Say something like this.squares[3][4].style.backgroundColor = "blue"; obviously this doesn't work is there something that does. I don't want to make a new div So i have this code and when you click on the first set of them (a specific one) it copys it and then when you click on one of the other ones it pastes it but its not working properly. (If you need to you can put an other image in there) Code: <script> var change = new Array change [0] = [0,0,0,0,0]; change [1] = [0,0,0,0,0]; change [2] = ["",0]; change [3] = [0,0,0,0,0]; function equipaa(){ change [0][0] = 1 change [0][4] = 0 change [0][1] = 0 change [0][2] = 0 change [0][3] = 0 changea(); } function equipab(){ change [0][1] = 1 change [0][0] = 0 change [0][4] = 0 change [0][2] = 0 change [0][3] = 0 changea(); } function equipac(){ change [0][2] = 1 change [0][0] = 0 change [0][1] = 0 change [0][4] = 0 change [0][3] = 0 changea(); } function equipad(){ change [0][3] = 1 change [0][0] = 0 change [0][1] = 0 change [0][2] = 0 change [0][4] = 0 changea(); } function equipae(){ change [0][4] = 1 change [0][0] = 0 change [0][1] = 0 change [0][2] = 0 change [0][3] = 0 changea(); } function equipba(){ change [1][0] = 1 change [1][4] = 0 change [1][1] = 0 change [1][2] = 0 change [1][3] = 0 changefinal(); } function equipbb(){ change [1][1] = 1 change [1][0] = 0 change [1][2] = 0 change [1][3] = 0 change [1][4] = 0 changefinal(); } function equipbc(){ change [1][2] = 1 change [1][0] = 0 change [1][1] = 0 change [1][3] = 0 change [1][4] = 0 changefinal(); } function equipbd(){ change [1][3] = 1 change [1][4] = 1 change [1][0] = 0 change [1][1] = 0 change [1][2] = 0 changefinal(); } function equipbe(){ change [1][4] = 1 change [1][0] = 0 change [1][1] = 0 change [1][2] = 0 change [1][3] = 0 changefinal(); } function changea(){ if(change [0] [0] = 1){ change [2] [0] = document.getElementById("is1i").src; change [2] [1] = change [3] [0]; } else if(change [0] [1] = 1){ change [2] [0] = document.getElementById("is2i").src; change [2] [1] = change [3] [1]; } else if(change [0] [2] = 1){ change [2] [0] = document.getElementById("is3i").src; change [2] [1] = change [3] [2]; } else if(change [0] [3] = 1){ change [2] [0] = document.getElementById("is4i").src; change [2] [1] = change [3] [3]; } else if(change [0] [4] = 1){ change [2] [0] = document.getElementById("is5i").src; change [2] [1] = change [3] [4]; } } function changefinal(){ if(change [1] [0] = 1){ document.getElementById("i1").src = change [2] [0]; } else if(change [1] [1] = 1){ document.getElementById("i2").src = change [2] [0]; } else if(change [1] [2] = 1){ document.getElementById("i3").src = change [2] [0]; } else if(change [1] [3] = 1){ document.getElementById("i4").src = change [2] [0]; } else if(change [1] [4] = 1){ document.getElementById("i5").src = change [2] [0]; } clear(); } function clear(){ change [0] [0] = 0; change [0] [1] = 0; change [0] [2] = 0; change [0] [3] = 0; change [0] [4] = 0; change [1] [0] = 0; change [1] [1] = 0; change [1] [2] = 0; change [1] [3] = 0; change [1] [4] = 0; } </script> <html> <body> <table border="0"> <tr> <td><div ><img onclick="equipba()" id="i1" src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> <td><div ><img onclick="equipbb()" id="i2" src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> <td><div ><img onclick="equipbc()" id="i3" src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> <td><div ><img onclick="equipbd()" id="i4" src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> <td><div ><img onclick="equipbe()" id="i5" src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> </tr> </table> <div id="invent"> <table border="o"> <tr> <td><div ondblclick="dropa();" onclick="equipaa();"><img id="is1i" src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> <td><div id="is1n"></div></td> <td><div id="is1d"></div></td> <td></td> </tr> <tr> <td><div ondblclick="dropb()" onclick="equipab();"><img id="is2i" src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> <td><div id="is2n"></div></td> <td><div id="is2d"></div></td> <td></td> </tr> <tr> <td><div ondblclick="dropc()" onclick="equipac();"><img id="is3i" src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> <td><div id="is3n"></div></td> <td><div id="is3d"></div></td> <td></td> </tr> <tr> <td><div ondblclick="dropd()" onclick="equipad();"><img id="is4i"src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> <td><div id="is4n"></div></td> <td><div id="is4d"></div></td> <td></td> </tr> <tr> <td><div ondblclick="drope()" onclick="equipae();"><img id="is5i" src="http://i1188.photobucket.com/albums/z417/sherlockturtlee/itemblank.png"/></div></td> <td><div id="is5n"></div></td> <td><div id="is5d"></div></td> <td></td> </tr> </table> </body> </html> |