html codes?

ok i need a code that make a code that makes a button that if clicked changes the background to a picture also i already have it to were it is different colors i need a pic as the background p.s. there is no background now well this a part to a code the code is for colors and i want one that does images and cati thanks actually sorry for some reason cati ur code doesnt work i mean the first one thanks i got the second one to work uhm well wat im doing is using coffecup html eitor to make html files to make a portal editor**** <SCRIPT> <!-- var click = 0; var pic = new Array(); pic[0] = ''; pic[1] = 'file:/me/pictures/pic.jpg'; function clickyYay() { click++; click %= 2; document.body.background = pic[click]; } //--> </SCRIPT> <INPUT TYPE="submit" VALUE="Click for MSU background" onClick="clickyYay()"> ok this is the code im using the pic is stored in my psp at file:/me/pictures/pic.jpg and when im on my psp it doesnt work how can i fix this and it is the right link thing im sorry helpin me is a hassle but if i upload the image to imageshack.us can i put the link there well when i cick the button nothing happens here is the whole script i am using the bottom one is the one i cant get the age is ony my psp 1st half <FORM name="changeColor"> <FONT face="Verdana,Arial,Helvetica,Sans Serif" size="2">Choose a Background Color: <BR><BR> <INPUT type="button" onClick="document.bgColor='#0000FF'" name="colr" value=" BLUE "> <INPUT type="button" onClick="document.bgColor='#FF0000'" name="colr" value=" RED "> <INPUT type="button" onClick="document.bgColor='#00FF00'" name="colr" value=" GREEN "> <INPUT type="button" onClick="document.bgColor='#FFFFFF'" name="colr" value=" WHITE "> <INPUT type="button" onClick="document.bgColor='#000000'" name="colr" value=" BLACK "></FONT> </form> <p>type watever: <br> <textarea NAME="comments" ROWS="5" COLS="50" wrap="virtual"> </textarea> </p> 2nd part <form name="Menu1"> <p><select name="Link" size="1"> <option selected value="C:\Documents and Settings\Aaron\Desktop\me\index.html">Select an Option</option> <option value="file:/me/index.html">Home</option> <option value="file:/me/me.html">form test</option> <option value="file:/me/htmleditor.html">html editor</option> <option value="file:/me/gamesh2.html">games</option> </select><input type="button" value="Go" onClick="window.location = document.Menu1.Link.options[document.Menu1.Link.options.selectedIndex].value;"> </p> </form> <SCRIPT> <!-- var click = 0; var pic = new Array(); pic[0] = ''; pic[1] = 'file:/me/pic.jpg'; function clickyYay() { click++; click %= 2; document.body.background = pic[click]; } //--> </SCRIPT> <INPUT TYPE="submit" VALUE="Click for MSU background" onClick="clickyYay()"> imageshack.us link http://img248.imageshack.us/img248/1919/picgl0.jpg the html is in file:/me

Public Comments

  1. search the web for htlm creation.
  2. You'll need to use javascript or something similar to add this functionality to your site, you cannot do this with html alone.
  3. your want the button to activate a line something like this: <body background="clouds.gif"> sounds like you already have the button changing a line like: <body bgcolor="black"> looks like you are almost there, the link might give you some more ideas
  4. Here's a quick (very simple) code: <INPUT TYPE="submit" VALUE="Click for picture background" onClick=" document.body.background = 'backgroundimage.jpg'"> backgroundimage.jpg being the name of the background image file. With this, you click the button, and the picture "backgroundimage.jpg" will appear as the background image. After that, the button doesn't do anything. See, I'm not sure what exactly you want to do though. Do you want the picture to change with each click? Do you want the background image to leave on the second click? All this is possible, but requires more code that I don't really want to write unless you actually want it. :D Clarify, and I will do! --- Edit: I decided to fool around a bit more, and here's a code that will bring the background image up first click, and then get rid of it on the second click. <SCRIPT> <!-- var click = 0; var pic = new Array(); pic[0] = ''; pic[1] = 'backgroundimage.jpg'; function clickyYay() { click++; click %= 2; document.body.background = pic[click]; } //--> </SCRIPT> <INPUT TYPE="submit" VALUE="Click for picture background" onClick="clickyYay()"> Probably a bit more useful, but I'm still not sure what you're looking for. --- Isn't working? Hmm -- it's working for me. I checked it in both Firefox and IE 7 -- what browser are you using? There's a chance that I might have used some incompatible JavaScript (I know how to write it, but I haven't used it enough to know the "dos" and "don'ts". But I don't think I did anything weird. Just to check -- one, is the code in the BODY section of the page? And two, is your image called backgroundimage.jpg or did you change "backgroundimage.jpg" to whatever your file is named? Because if it can't find the picture, then it will look like nothing is happening. If neither version of the code will work, than it's probably a problem with the script not pointing to the image. Or you don't have JavaScript turned on, but since you've been playing with a color change script, I'm sure that you do... *pauses* Double check the image stuff and let me know what browser you're using, and we'll see if we can figure this out. :D --- Edit: Okay, awesome! Do you want the script to do more than that? --- Okay, I've never even touched a PSP, but try using "file://me/pictures/pic.jpg" instead of "file:/me/pictures/pic.jpg". If that doesn't work, where is the page itself located? Say, if it's located in /me, you could then use "/pictures/pic.jpg" as the address to the picture. --- Yep! As long as you're connected to the internet (Again, I have no idea how PSPs work, LOL). --- Okay. Can you post the script as you're using it now (with the Imageshack URL and all)? And where is the page with the script at -- is it on the PSP, or on the internet, or just on your computer? It'll help to figure this out. --- Okay, since the HTML is in file:/me and the picture is currently in the same spot, you should be able to just put "pic.jpg" instead of "file:/me/pic.jpg". Try that first, if you haven't already. :)
Powered by Yahoo! Answers