I am using this code. I am using the internal script. I am able to see the selection first; But the price of the second selection is not changing due to the first selection. I'm missing some basic things, please help. Please provide an example.
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Body & gt; & Lt; Script & gt; $ (Document) .ready (function () {$ ("# type"). Change (function () {var val = $ (this) .val (); if (val == "item1") {$ (" Html ("option value = 'test'> item1: test1 option & lt; value = 'test2' & gt; item 1: test 2 & lt; / option Html ("& lt; Option value = 'test' & gt; item 2: test1 & lt; / etc) (value ==" item 2 ") {$ (" # 2 ") Option & gt; Option value = 'test2' & gt; Item 2: HTML ("& lt; Option value = 'test'> item 3: test 1 & lt; / option & gt; test 2 & Lt; / option & gt; "; else if (val ==" item3 ") {$ (" & lt; option value = 'test2' & gt; TEM 3: Exam 2 & lt; / option & gt; ");}})}}; & lt; / script & gt; & lt; select id =" type "& gt; & lt; option value =" Item 1 "& gt; item 1 & lt; / option & gt; option value =" item 2 "& gt; item 2 & lt; / option & gt; option value =" item 3 "& Gt; Item 3 & lt; / option & gt; & lt; / select & gt; & lt; id = "size" & gt; select & lt; option value = "" & gt; - Choose one - & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Body & gt; & Lt; / Html & gt;
You have not imported jquery which is a problem copy and paste below HTML code in HTML code
& lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "http://code.jquery.com/jquery-1.10.1.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ("# type"). Change (function () {var val = $ (this) .val (); if (val == "item1") {$ (" Html ("option value = 'test'> item1: test1 option & lt; value = 'test2' & gt; item 1: test 2 & lt; / option Html ("& lt; Option value = 'test' & gt; item 2: test1 & lt; / etc) (value ==" item 2 ") {$ (" # 2 ") Option & gt; Option value = 'test2' & gt; Item 2: HTML ("& lt; Option value = 'test'> item 3: test 1 & lt; / option & gt; test 2 & Lt; / option & gt; "; else if (val ==" item3 ") {$ (" & lt; option value = 'test2' & gt; TEM 3: Exam 2 & lt; / option & gt; ");}});}); & lt; / script> gt; & lt; / head & gt; & lt; body & gt; & lt; Id = "type"> item 1 gt; option value = "item 2" & gt; item 2 & lt; / Option & gt; Option Value = "Item 3" & gt; Item 3 gt; & gt; Selection & gt; & lt; id = "Size" & gt; Select & lt; Option value = "" & gt; - Choose one - & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Body & gt; & Lt; / Html & gt;
No comments:
Post a Comment