View Full Version : Click to Activate?

01-11-2007, 04: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.


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

<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 = "";
<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>
<br />
<div id="adiv" style="">Select something.</div>
<div id="bdiv" style="display:none"><img src="images/pizza.jpg" onclick="document.f.submit();" /></div>


01-12-2007, 12: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!



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

Fantastic, and thanks for such a fast response.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum