PDA

View Full Version : need help with my small code



Alidad
03-31-2009, 05:00 PM
Hi, i'm trying to write code in php with javascripts, to see the sample please see sample from ask.com where you see image background with search text field form on the forground behind image.

I have developed that when loading is showing first style backgroundimage, then person select image from the menu it will change style background image, the problme is that every time select image from the menu it will show on different page with different url address.

I want to show in same page using (div) on the line where it said "<img name="previewpic" src="background/City/Snow-city2.png" width=150 height=113 border=1>' how can i write code in with div to show in same page when person select images from the menu.

please see code:


<SCRIPT LANGUAGE="JavaScript">



function previewPic(sel) {
document.previewpic.src = "" + sel.options[sel.selectedIndex].value;
}
function showPic(sel) {
images = new Array();
images[1] = "background/City/Nice-City-1.png";
images[2] = "background/City/Nice-City-3.png";
images[3] = "background/City/Snow-city.png";
images[4] = "background/City/Snow-city2.png";
images[5] = "background/City/Snow-city3.png";
images[6] = "background/City/Snow-city2.png";
window.location.href = images[sel.selectedIndex+1];
}

</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>
<form name=picform>
<select name=selbox size=1 onChange="previewPic(this)">
<option value="background/City/Nice-City-1.png">Axe
<option value="background/City/Nice-City-3.png">Castle
<option value="background/City/Snow-city.png">Iceberg
<option value="background/City/Snow-city2.png">Ocean
<option value="background/City/Snow-city3.png">Olympus
<option value="background/City/Snow-city2.png">Temple
</select>
<p>
<img name="previewpic" src="background/City/Snow-city2.png" width=150 height=113 border=1>
<p>
<input type=button value="Show Image" onclick="showPic(this.form.selbox)">
</form>
</center>
</p>
</p>
</body>
</html>

please help thansk.

AM

Risenprogrammer
04-02-2009, 02:20 AM
Just a quick question...
What is this for?

Nile
04-02-2009, 02:22 AM
By looking at the code it selects pictures.