Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Click to Activate?

    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
    Last edited by cadoga; 01-11-2007 at 04:08 PM. Reason: typos

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this. Hopefully it will get you started.

    Code:
    <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

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It worked a treat.

    Fantastic, and thanks for such a fast response.

    Barry


  •  

    Posting Permissions

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