# Set and use variable after HTML select tag option selection

**URL:** <https://discourse.nodered.org/t/set-and-use-variable-after-html-select-tag-option-selection/53532>\
**Category:** Developing Nodes\
**Created:** [10 November 2021 18:40 UTC](https://discourse.nodered.org/t/set-and-use-variable-after-html-select-tag-option-selection/53532 "2021-11-10T18:40:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NicoloToscani](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@NicoloToscani](https://discourse.nodered.org/u/NicoloToscani)\
**Post date:** [10 November 2021 18:40 UTC](https://discourse.nodered.org/t/set-and-use-variable-after-html-select-tag-option-selection/53532/1 "2021-11-10T18:40:49Z")

</div>

Hi,  
I'm working on a new node and I have a question about a HTML `<select>` tag.  
I need to set a variable based on which option is selected.

After this I need to use the value of this variable for show different `<select>` tag whit different option.

For example:

````auto
<script type="text/x-red" data-template-name="node">
        
    <div class="form-row">
        <label for="node-input-name"><i class="icon-tag"></i> Name</label>
        <input type="text" id="node-input-name" placeholder="Name">
    </div>
    <div class="form-row">
        <label for="node-input-unitId"><i class="icon-tag"></i> Unit ID</label>
        <input type="text" id="node-input-unitId" placeholder=" 123">
    </div>
    <div class="form-row">
        <label for="node-input-device"><i class="icon-tag"></i> Device</label>
        <select id="node-input-device" name="node-input-device">
           <option value="item1">ITEM 1</option>
           <option value="item2">ITEM 2</option>
        </select>
    </div>

If(node-input-device.value == item1):
          ```
          <div class="form-row">
       <label for="node-input-data"><i class="icon-list"></i> Values</label>
       <select id="node-input-data">
           <option value="a">A</option>
           <option value="b">B</option>
         ```
Else If(node-input-device.value == item2):
          ```
          <div class="form-row">
               <label for="node-input-data"><i class="icon-list"></i> Values</label>
               <select id="node-input-data">
                     <option value="c">C</option>
                     <option value="d">D</option>
               </select>
           </div>
</script>

````

Any suggestions?

Nicolò

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [10 November 2021 20:01 UTC](https://discourse.nodered.org/t/set-and-use-variable-after-html-select-tag-option-selection/53532/2 "2021-11-10T20:01:38Z")

</div>

jQuery is your friend here. It is available to you in the editor. You can dynamically select or even compose selects with it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 November 2021 20:02 UTC](https://discourse.nodered.org/t/set-and-use-variable-after-html-select-tag-option-selection/53532/3 "2021-11-24T20:02:16Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
