In this I have a select box with options. The value of options is found in the item ID of each option. .
I have another value, which should be linked to this option. Is there an easy way to do this?
& lt; Id = "category" name = "data [cat]" & gt; & Lt; Option value = "12" label = "0" & gt; A & lt; / Options & gt; & Lt; Option value = "7" label = "0" & gt; B & lt; / Options & gt; & Lt; / Select & gt;
I tried to do this to enter the second value in the label value, but then the problem is that I do not know the correct way to get the label value of the selected option. It has been written in jQuery.
To get the selected option:
$ ("# category"). Livequery ('change', function () {var CatId = ($ (this) [0] .value);});
It works great, but I do not know how to get the label value of the selected option. Or maybe a better way of solving this problem.
label
is the attribute that is displayed by some browsers to display content of the option , Your list box may display two 0
options.
There may be a better way to do the following:
& lt; Id = "category" name = "data [cat]" & gt; & Lt; Option value = "12,0" & gt; A & lt; / Options & gt; & Lt; Option value = "7,0" & gt; B & lt; / Options & gt; & Lt; / Select & gt;
and divide the value into the event handler, such as
$ ("# category"). Livequery ('change', function () {var value = ($ (this) [0] .value) .split (","); var catId = value [0]; var other IID = value [1];} );
Comments
Post a Comment