Liquid, JavaScript, themes, sales channels
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.
User | RANK |
---|---|
38 | |
24 | |
13 | |
11 | |
8 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023