...

View Full Version : Click to Activate?



cadoga
01-11-2007, 05:06 PM
Would really appreciate some help. I normally use PHP so am new to JS.

I have a set of 5 radio buttons, and an image you click to submit. I'd like some text like 'Please Make a Selection' to appear, and when one of the buttons has been selected, the text is replaced by the image button. Alternatively the image could be there all the time, and if you click submit image without having made a selection, a warning is displayed and the form not submitted.

Have tried playing around with onfocus, but its beyond my level of experience.

Barry
www.EasternSilver.co.uk

david_kw
01-11-2007, 11:40 PM
Try this. Hopefully it will get you started.



<html>
<head>
<title>On Click</title>
<script type="text/javascript">
function doIt(s) {
var adiv = document.getElementById("adiv");
adiv.innerHTML = s;
}

function changed() {
document.getElementById("adiv").style.display = "none";
document.getElementById("bdiv").style.display = "";
}
</script>
</head>
<body>
<div>
<form name="f" action="#" onclick"changed();">
<input type="radio" name="button" value="1" onclick="changed();">One</input>
<input type="radio" name="button" value="2" onclick="changed();">Two</input>
<input type="radio" name="button" value="3" onclick="changed();">Three</input>
<input type="radio" name="button" value="4" onclick="changed();">Four</input>
<input type="radio" name="button" value="5" onclick="changed();">Five</input>
</form>
<br />
<div id="adiv" style="">Select something.</div>
<div id="bdiv" style="display:none"><img src="images/pizza.jpg" onclick="document.f.submit();" /></div>
</div>
</body>
</html>


david_kw

cadoga
01-12-2007, 01:32 PM
Thanks David

This seems to be exactly what I'm looking for.

I'm about to try combining your script with my page!

Cheers

Barry

cadoga
01-12-2007, 02:44 PM
It worked a treat.

Fantastic, and thanks for such a fast response.

Barry



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum