Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:29:13+00:00 2026-06-17T21:29:13+00:00

I am a bit confused with the switch statement, i need it for my

  • 0

I am a bit confused with the switch statement, i need it for my home page. I’ll explain shortly: i have two groups of radio buttons on my html code, each consisting of three buttons. According to the button selected an image will be shown (means three different images for one group and three different for the other). There are shown also two images at a time. This works with my code so far. What I would like to do next is to show a third image according to the combination of buttons chosen. This is my code so far

    <html>
<head>
<title>Radio-Buttons</title>
</head>
<body>

<h1>Testing</h1>

<script language='JavaScript' type='text/javascript'>


    function check_value(fieldvalue)
    {    

        switch(fieldvalue)
        {
            case 1:

                document.getElementById("imagedest").innerHTML = "<img src='image1.jpg'>";

                    break;

            case 2:

                document.getElementById("imagedest").innerHTML = "<img src='image2.png'>"; 

                    break;

            case 3:

                document.getElementById("imagedest").innerHTML = "<img src='image3.jpg'>"; 

                    break;
        }

   }
    function check_other_value(fieldvalue)
    {   

        switch(fieldvalue)
        {
            case 1:

                document.getElementById("imagedest2").innerHTML = "<img src='image4.jpg'>";



            break;

            case 2:

                document.getElementById("imagedest2").innerHTML = "<img src='image5.png'>";


        break;

            case 3:

                document.getElementById("imagedest3").innerHTML = "<img src='image6.jpg'>";

    }

    }


</script>

<form name='test'>
    <input type="radio" name="field" value="one" onclick='check_value(1)'>one 
    <input type="radio" name="field" value="two" onclick='check_value(2)'>two 
    <input type="radio" name="field" value="three" onclick='check_value(3)'>three 
</form>

<div id='imagedest'>
</div>


<form name='tests'>
    <input type="radio" name="fields" value="one" onclick='check_other_value(1)'>one 
    <input type="radio" name="fields" value="two" onclick='check_other_value(2)'>two 
    <input type="radio" name="fields" value="three" onclick='check_other_value(3)'>three 
</form>

<div id='imagedest2'>
</div>



</body>
</html>

This code works for what i descrived previously. I thought on using an “if” statement to check the first case selected, but as far as i understand, after the “breaks” the function “erases” everything and starts from 0.

Can anybody give me an idea on how to make it work?

Thank you,
Jordi

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:29:14+00:00Added an answer on June 17, 2026 at 9:29 pm

    You have to pass both values to a third function and do whatever checks you need to do there.

    function check_third_value( field1, field2 )
    {
        if( field1 == 1 && field2 == 2 ) {
            // do something
        } else if( field1 == 2 && field2 == 2 ) {
            // do something else
        } else if...
    }
    

    How you pass the values depends on how you trigger the changes. You can also get the values with document.getElementById("fieldID").value, depending on your HTML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a bit confused about the understanding of a mode switch in Unix kernel.
Bit confused here, I have an on-demand instance but do I get charged even
I'm willing to switch from AWS to Azure, however I'm a bit confused on
Bit confused with this one. Basically, I have a column in a table, and
Bit confused with this one so bear with me... I have a Navigation-based project
I have create a segmented button in android , now i am bit confused
I'm new to Git and a bit confused. I have a Master branch and
I'm a bit confused about STI in rails. My situation: I have a Contact
bit confused here with what's wrong with my query. I have about 9 records
I am bit confused so, thought to ask experts. I have written small java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.