hello all
lets say i have a drop down list (its name = typeddl) with 2 item House and Car
and i have another drop down list for car model and another one for house type
now what i want is: when i choose House from the 1st dropdwon list , hide the cars model drop down list and show the house type drop down list....
i tried this below but didnt work
export function typeddl_change(event, $w) {
//Add your code for this event here:
if ( this.value === '1') { $w('#carddl').show('');
$w('#houseddl').hide(''); } else {
$w('#carddl').hide(''); $w('#yearddl').show(''); } }
i hope you got my point
many thanks
yes, its working :) thanks a lot , but the thing i dont get it ...
if the selection = house , it suppose to hide the year ddl ( the first part of if should work ) but it work the other way
The === operator means: equal value and equal type
Did you try my code?
does === mean if not equal ?!, if yeas so the issue was that from the first place , thats why i thought your code is not working for me ...
You need to compare the actual value returned by the dropdown (House, Car):
export function typeddl_change(event, $w) { let value = event.target.value; if(value === 'House') { $w('#yearddl').show(); } else { $w('#yearddl').hide(); } }
See the Dropdown API for more information.
at the end now is working but i used this code below :
export function typeddl_change(event, $w) { let value = event.target.value; if(value === '2') { $w('#yearddl').hide(); } else { $w('#yearddl').show(); } }
valu no 2 is the second option in the drop down list ???!!!!!!!!!!!! this a bit confusing
i tried this code still not working , and im not getting any errors :
export function typeddl_change(event, $w) { let value = event.target.value; if(value === '1') { $w('#yearddl').show(); } else { $w('#yearddl').hide(); } }
thanks a lot for your continuous support, actually i tried your code too didn't work, so i google it and i tired this also didn't work...
im new to wix and code , could you please test on my site which code will do the work for me...
many thanks
Hey Siyamand,
I found the following code on your CarsModel page:
export function typeddl_change(event, $w) { //Add your code for this event here: if ($w(this).val() === "1") { $w('#yearddl').show(); } else { $w('#yearddl').hide(); } }
This is not valid Wix Code and simply will not work. You will need to rewrite it in valid Wix Code as I showed in a previous post.
Refer to the Wix Code docs for details.
Good luck,
Yisrael
What page do you need help with?
aha sorry for misunderstanding , i have a copy of my actual site, in order to do the tests and migrate it when its success ,
here is the site where im doing the test on it
https://siamand6.wixsite.com/website-17
https://editor.wix.com/html/editor/web/renderer/edit/d9731382-8ae7-4e01-872c-9d310189a0f5?metaSiteId=5a29cbfe-4b0c-46ba-9108-8ff56a9ade0b&editorSessionId=9704c211-2220-4b5a-90ee-c5070224b665&referralInfo=my-account
What is the URL of your site?
thanks a lot for your help, here is the link https://www.aspsnippets.com/Articles/Show-Hide-DIV-with-TextBox-based-on-DropDownList-Selected-Value-Selection-using-JavaScript-and-jQuery.aspx
jQuery won't work inside of Wix Code.
Please post the URL of your site and I’ll take a look. Only authorized Wix personnel can get access to your site in the editor.
i found this working example on internet which is done with juqery , but i dont know how to make it work with my wix website :
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("#ddlPassport").change(function () {
if ($(this).val() == "Y") {
$("#dvPassport").show();
} else {
$("#dvPassport").hide();
}
});
});
</script>
<span>Do you have Passport?</span>
<select id="ddlPassport">
<option value="N">No</option>
<option value="Y">Yes</option>
</select>
<hr />
<div id="dvPassport" style="display: none">
Passport Number:
<input type="text" id="txtPassportNumber" />
</div>
Thanks a lot Yisrael, this still not work :( please i need this so much
regards
You are not retrieving the selected value correctly. You need to do something like this:
export function typeddl_change(event, $w) { let value = event.target.value; if(value === '1') { $w('#carddl').show(); $w('#houseddl').hide(); } else { $w('#carddl').hide(); $w('#yearddl').show(); } }
Good luck,
Yisrael
Thanks a lot for reply
i already used cascading to filter my second drop down list ,
but my design requires to hide the drop down completely
for example if i choose car in the first drop down i need 3 drop down lists , one for year , one for make and one for model... but when i choose house i need one dropdown list for type of houses ...
i hope you got me ..
many thanks
Hi,
The Cascading Form example does pretty much what you want. You can start with that and then modify it for your own use.
Good luck,
Yisrael