ahouston
ahouston

Reputation: 11

On button click passing a radio value to the option list selected

Need your help. The subject is:

I got a set of radio buttons and a submit like this:

<input type="radio" value="1" name="strange1" id="for_2" /><label for="for_2">600 Wt</label>
<input type="radio" value="2" name="strange1" id="for_3" /><label for="for_3">800 Wt</label>
<a href="#orderform" class="button_1 scrollto">Buy</a>

When pressing the button the page scrolls down to the order form and there is the list:

<select class="select" id="name_1" name="name_1">
<option value="1">Item 1</option>
<option value="2">Item 2</option>
</select>

The question is how can I choose a radio button, then click "Buy" and get an appropriate option selected in the list below?

Thanks in advance.

Upvotes: 1

Views: 83

Answers (1)

BarryDevSF
BarryDevSF

Reputation: 405

Try this:

$(document).ready(function(){

 $(".button_1").click( function() {

    $("#name_1").val(  $("input:checked").val()  );

 });

});

Upvotes: 1

Related Questions