1

Hi I have tried below code to reset number of "adults" dropdown field on onclick of reset button but the dropdown field is not getting reset please suggest

Code for adult dropdown :

<select class="select_style sel_ad_{$smarty.section.sect.iteration}" id="adult[]" 
name="adult[]"
onchange="javascript:display_twin('{$smarty.section.sect.iteration}',this.value)">
<option value="0"> - </option>
{section name=adult loop=10 start=1 step=1} 
<option value="{$smarty.section.adult.index}" {if $adults_details.$sect_key eq 
 $smarty.section.adult.index}selected{/if}>{$smarty.section.adult.index} </option
 {/section} 
 </select>

Javascript code for reseting fields onclick of reset button :

 function reset_frm(){
    $("#adults_pkg").val('');
    //$("select[name='adults_pkg[0]']").val('');
 }
1
  • The id adult[] and adults_pkg do not match Commented Dec 9, 2014 at 6:28

3 Answers 3

1

You are passing wrong id.

To use existing code:

$('#adult\\[\\]').val('');

OR

Add a new class to the element:

<select class="pkgCls select_style sel_ad_{$smarty.section.sect.iteration}" id="adult[]" 
name="adult[]"
onchange="javascript:display_twin('{$smarty.section.sect.iteration}',this.value)">

And apply this:

$(".pkgCls").val('');
Sign up to request clarification or add additional context in comments.

1 Comment

@pihu, then please choose my answer as solution.
0

Default mean selected first option of select value, as you have have 0 value on first index so you will need to assign 0 for default index

And selector seems wrong, support the select box inside loop so use right selector like

        $(".sel_ad_{$smarty.section.sect.iteration}").val('0');

Comments

0

Try with -

$("yourSelectMenu").prop('selectedIndex',0);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.