SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Required - Please Help?

    Hi Sitepointers,

    I am in need for alittle piece of javascript which is as follows:

    On a web page is a image with a text box underneath.

    I need some javascript which changes the image based on the url in the text box associated with the textbox. so for example :

    PICTURE = BOAT

    TEXT BOX = www.website.com/boat.jpg

    then if i change TEXT BOX to www.website.com/tree.jpg

    then the picture would change to a picture of a tree.

    Thanks for help...

    Rodent

  2. #2
    SitePoint Evangelist borna's Avatar
    Join Date
    Jun 2006
    Location
    Iran, Tehran
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That doesn't sound too difficult. Take a look at
    Code:
    <html>
    <head>
    <script language="javascript">
    function loadradio()
    {
    	document.myForm.IP.value = "";
    	for(var i = 0; i< document.myForm.radio.length; i++)
    	{
    		if(document.myForm.radio[i].checked)
    		{
    			document.myForm.IP.value = document.myForm.radio[i].value;
    			document.body.bgColor = document.myForm.radio[i].value;
    		}
    
    	}
    }
    </script>
    </head>
    <body onLoad = "loadradio()" bgcolor = "green">
    <form name="myForm">
    <input type="text" name="IP" value="">
    <input type="radio" name="radio" value="red" onclick = "loadradio()">red
    <input type="radio" name="radio" value="blue" onclick = "loadradio()">blue
    <input type="radio" name="radio" value="green" onclick = "loadradio()">green
    <input type="radio" name="radio" value="violet" onclick = "loadradio()">violet
    </form>
    </body>
    </html>
    It'll give you the idea of the required code.
    -1/2=999?

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the link...unfortuantely my Javascript knowledge is less than acceptable...so if anyone cares to help some more (im sure using the posted code above will help some one more capable than myself)

    Thanks any how mate

    Rodetn

  4. #4
    SitePoint Evangelist borna's Avatar
    Join Date
    Jun 2006
    Location
    Iran, Tehran
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wouldn't you mind to tell us weather you could use such code for your case or not.

    It needs some modifications of course.
    -1/2=999?

  5. #5
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry...I think the principle of the code may work...but when i said my javacript was less than impressive, its more like non-existant.

    Basically there needs to be a picture and a url box...and when the text in the box changes to another url of another picture, then the image will change to that picture.

    This needs to be done without pressing a button...

    Rodent

  6. #6
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this some kind of homework assignment?

  7. #7
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No...This is for a job..but i cannot for the life of me work it out...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •