overflowstack9 overflowstack9 - 3 months ago 4x
jQuery Question

How can i give numbering for option values

The below is my code but i want to give number for every value like this

<option value="1" />vijay

should be there because i want to assign some values using jquery thats i want to add + value as we can modify
<option value="1" />vijay

but due to my template design i want to give like this
<option value="1" value=vijay+/>vijay
i dont think it is correct what is the correct format.

<select id="cmbColumn">
<option value="" />Columns
<option value="apple+" />apple
<option value="berry+" />berry

<select id="cmbSidebar" name="cmbSidebar">
<option value="" />Sidebars
<option value="grapes+" />grapes
<option value="mango+" />mango

my main aim is to achieve for example like for all values apple+ and apple and also giving number to the values.

This is my other code but i want to give numbering to values like this but like i above said i also need grapes+ values with them

<select id="cmbsidebar">
<option value="1" />vijay
<option value="2"/>1004045


<select id="combo-014">
<option value="1" />1003045
<option value="2" />1004045



You can use data attributes together with the value attribute like this:

document.getElementById("options").onchange = function(e) {
  // Get the selected option element
  var target = e.explicitOriginalTarget;
  // Get its value
  // Get its data-value
<select id="options">
  <option value="">Sidebars</option>
  <option value="1" data-value="grapes+">grapes</option>
  <option value="2" data-value="mango+">mango</option>