How is it possible to rely on two dropdown lists? If country X is selected, dropdown Y is visible. If country A is selected, dropdown Y is hidden and dropdown Z is visible and so on. I am creating the dropdown menu as follows:
& lt; Div class = "form-group {{($ errors-> ('country')) 'has-error': ''}}" & gt; & Lt; Label class = "col-sm-2-control-label" & gt; Country & lt; / Label & gt; & Lt; Div class = "col-sm-10" & gt; {{Form :: Select ('country', $ country)}} if ($ errors-> ('country')) & lt; P class = "help-block" & gt; {{$ Errors- & gt; Last ('Country')}} & lt; / P & gt; @endif & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "form-group {{($ errors-> ('city')) 'is-error': ''}}" & gt; & Lt; Label class = "col-sm-2 control-label" & gt; City & lt; / Label & gt; & Lt; Div class = "col-sm-10" & gt; {{Form: hidden ('city', $ city)}} @ if ($ errors-> ('city')) & lt; P class = "help-block" & gt; {{$ Errors- & gt; Last ('city')}} & lt; / P & gt; @endif & lt; / Div & gt; & Lt; / Div & gt;
How can this be achieved ?!
T notice it was easy. The use of JavaScript / Ajax is as follows:
& lt; Script & gt; $ (Document) .ready (function () {$ ("select [name = 'country']) change (function () {// alert ($ (this) .val ()); if ($ (this) ($ ("Name ['name =' city ']"). () ($ ["Name =' city ']"). Show ();} else {$ ("select [name =' city '] "). Hide ();}}};}); & lt; / script & gt;
Comments
Post a Comment