javascript - HTML: select default option when select tag holds a function -


I have this dropdown:

  & lt; Select & gt; [_Perl function that creates and gives options]]   

There are only two options, current and previous, but the perl code "omits" option omits.

PRL Return

  "Option VALUE = \" $ item \ "SELECTED> $ item    

Where $ item is a entry in a dynamically-built list.

I have already asked if I can change this very complex design, but I do not have permission, I want to throw some JS on it, though, I do not know how with Pearl Have a conversation.

I found that you can hold the DOM element and in this case, the current or Set in the previous and it is not enough to add another option to your smartphone. It turns out that I did not have to deal with Pearl at all.

Onkidown in a text element I wanted to define to choose, my JS looks

  function defaults turned on (& lt; Domamement.name & gt; ) {If (& lt; DOMelement .name & gt; == "& lt; specific state as first & gt;") {var element = document.query selector ("# & lt; selectElementID»;) ; If (element.value == "") element.value = "current"; } And {& lt; Nothing-the first logic & gt; Var element = document.query selector ("# & lt; Selection ElementID";); If (element.value == "") element.value = "Previous"; }}   

Where no option is selected ("Select one" = null), then this is the default for proper position

The story is ethical, when you A traditional

  & lt; Select & gt; & Lt; Options & gt; & Lt; / Options & gt; & Lt; Options & gt; & Lt; / Options & gt; & Lt; / Select & gt;   

Also list, if it is needed.

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

Matlab transpose a table vector -

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -