Question

I'm completely new to javascript, but I'm trying to create a beta form for a focus group test. The end product will be professionally developed, but I need a short term, functioning solution. It only has to function one time on one computer, so I can use any method (cookies, webstorage, etc.) to transfer data between pages.

I have a form with a ddl with 10 options. For example:

<select name="sector" id="sectorchoice"><option value="religion">Religion</option><option value="health">Health</option></select>

I also have a radio button that will open one of two URLs depending on whether or not it is checked (onclick="greport"() through submit button).

 <script>
function greport() {
    if (document.getElementById('radio1').checked = true) {
        window.open ("http://www.sampleurl.com","mywindow");
    }

    if (document.getElementById('radio1').checked = false) {
        window.open ("http://www.sampleurl2.com","mywindow");
    }
}

I need to load one of nine images on sampleurl.com and sampleurl2.com based on the "sectorchoice" value in the first dropdown. How can I transfer the value and create a function to open the correct image? Thanks.

Was it helpful?

Solution

= and == are two different things.

= the assignment operator

var box = "A Big Box";

== is the comparison operator, and the statement returns a boolean

a == b 

so you will make this change in your code

document.getElementById('radio1').checked == true
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top