Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello
I am trying to add some extra input in the registration form conditionally, check my example code.
It is not working properly. Can anyone help me to fix the issue? It is always adding a customer tag
<select id="rd_customer_status">
<option>Select...</option>
<option value="Retailers">Retailers</option>
<option value="Distributors">Distributors</option>
</select>
<div id="showRetailers" class="myDiv">
<input type="hidden" name="customer[tags]" value="Retailers">
<label for="customer_store_address">Address</label>
<input type="text" id="customer_store_address" name="customer[note][Retailers Address]">
</div>
<div id="showDistributors" class="myDiv">
<input type="hidden" name="customer[tags]" value="Distributors">
<label for="d_customer_store_address">Address</label>
<input type="text" id="d_customer_store_address" name="customer[note][Distributors Address]">
<label for="customer_store_website">Website URL</label>
<input type="text" id="customer_store_website" name="customer[note][Website URL]">
</div>
<script>
$(document).ready(function(){
$('#rd_customer_status').on('change', function(){
var demovalue = $(this).val();
$("div.myDiv").hide();
$("#show"+demovalue).show();
});
});
</script>
Solved! Go to the solution
This is an accepted solution.
Hi @ikrama ,
It's because your customer[tags] is two times in code and since input is text type it will always override the previous selection.
To achieve it you should use radio button for which form will take only one value.
Replace your drop-down code with radio button and write your conditional code on their change event.
Rest will be same...
Hope it help...
This is an accepted solution.
Hi @ikrama ,
It's because your customer[tags] is two times in code and since input is text type it will always override the previous selection.
To achieve it you should use radio button for which form will take only one value.
Replace your drop-down code with radio button and write your conditional code on their change event.
Rest will be same...
Hope it help...
Yes, Thank you.
I am trying to create a conditional question in my registration form, I tried using what this user has suggested but it is not working... I just need something simple:
Are you a boy or girl radio buttons and then if the user selects boy it shows a text field and if user selects girl it shows a different text field. Can you please show me how the code should look? When I use the example above and try switching to radio, it just shows all the information still.
Im sorry dear I can help you to fix your existing code but writing code will require a job to offer.
Hope u understand.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024