/    Sign up×
Community /Pin to ProfileBookmark

Help – stumped with a javascript

I want to be able to have a few radio-button groups. Each group represent a small list of options. A person would be able to select one option from each group. Based on the selections when a you click on the submit button a .jpg is returned based on the options select.

Anyone know how to do this? I have included a .zip file with the example I am working with.

  • MB
  • [upl-file uuid=1e617917-4289-465f-ba0f-d32c1244d082 size=22kB]RadioValue.zip[/upl-file]

    to post a comment
    JavaScript

    4 Comments(s)

    Copy linkTweet thisAlerts:
    @HiyaMar 30.2006 — Why don't you, rather than leaving Text on the second page, leave an image, like:
    [CODE]document.write("<img src='...' height='...'>")[/CODE]for each possible selction or use a dynamic srcipt to do the possiblities for you.
    Copy linkTweet thisAlerts:
    @mbankeauthorMar 30.2006 — Agreed. However that is where my problem is. The image is not defined by just one option being selected, it's defined by multiple selections.

    Example; this is for a eCommerce site to purchase something, but the purchase option depends on some variables like; color and size. So the intention here is to have a customer be able to click on a prefered color and size and then based on those choices see a picture containing those choices. When they click "submit" the .jpg would pop up and present them with what they chose. So the document.write("<img src" entry somehow has to look at the chosen variables and chose the correct image to display.

    That is where I am stuck. I posted an example of the .html and test .jpg's in a .zip file along with my original post for people to look at.

    Any help is greatly appreciated.

  • - MB
  • Copy linkTweet thisAlerts:
    @jnosterMar 30.2006 — Will this help? You may be able to play with it to get what you need. You may also need to create a "begining" image so you don't have that ugly "image is supposed to be here" tag. There are other things that can be done, of course, but this is simple.

    [code=html]<html>
    <head>
    <title>Radio Button Values</title>
    <script language="JavaScript">
    <!--
    function diplayimg(newimg){
    var imgdisplay = document.getElementById('imgdisplay');

    imgdisplay.setAttribute('src', newimg);

    }

    //-->
    </script>
    </head>
    <body>
    <form action="javascript: subForm();">
    <input type="radio" name="r_1" Id="A" onclick="diplayimg('AA.gif');">A<br>
    <input type="radio" name="r_1" Id="B" onclick="diplayimg('BB.gif');">B<br>
    <input type="radio" name="r_1" Id="C" onclick="diplayimg('CC.gif');">C<br><br>
    <input type="radio" name="r_2" Id="A" onclick="diplayimg('AA.gif');">A<br>
    <input type="radio" name="r_2" Id="B" onclick="diplayimg('BB.gif');">B<br>
    <input type="radio" name="r_2" Id="C" onclick="diplayimg('CC.gif');">C<br><br>
    <br />

    <img id="imgdisplay"></img>
    </form>
    </body>
    </html>[/code]
    Copy linkTweet thisAlerts:
    @mbankeauthorMar 31.2006 — Excellent, thank you for the suggestions. I will give them a try and see what happens.

  • - MB
  • ×

    Success!

    Help @mbanke spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.5,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...