Click to See Complete Forum and Search --> : resizing an image using radio buttons?


Lon
08-26-2003, 09:36 AM
:confused: I have been trying to write a little script to change an image size by percent using radio buttons? I don't need to use radio buttons but only want to give an exact input that a button would give me. My script in "HTML" is below. (it don't work yet)......

<form name="cSize" method="document">
<input name="percent" type="radio" value="40%">40% (Smaller)<br>
<input name="percent" type="radio" checked value="50%">50% (good)<br>
<input name="percent" type="radio" value="70%">70% (Bigger)<br>

<img src="lon 004.jpg" getimagesize("lon 004.jpg");width="auto" height="percent" alt="004">
</form>

can anyone help with this? I think that it needs to be done in java?
Lon

Fang
09-09-2003, 03:03 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>ImagePercent</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

<script type="text/javascript">
<!--
function ImagePercent(val) {
var oImg=document.images['img004'];
oImg.height=parseInt(150*val/100);
oImg.width=parseInt(250*val/100);
}
//-->
</script>

</head>
<body>
<input name="percent" type="radio" value="50%" onclick="ImagePercent(50);">50% (Smaller)<br>
<input name="percent" type="radio" checked value="100%" onclick="ImagePercent(100);">100% (good)<br>
<input name="percent" type="radio" value="150%" onclick="ImagePercent(150);">150% (Bigger)<br>

<img name="img004" src="lon 004.jpg" width="250" height="150" alt="004">

</body>
</html>

Learn HTML and Javascript (http://www.w3schools.com/default.asp)