1

For example if i have a list item like all,a,b,c,d. if i click all means it should not allow to choose other items, if i am not choosing all means it should allow to choose mulitle item from list

2 Answers 2

2
<script type="text/javascript">
  var creatLimit = 5;
  var fCount = 0;
  function addFileElement()
  {
      if(fCount < creatLimit)
      {
        var fObject = document.getElementById("name");
        var addButton = document.createElement("select");
        addButton.type = "select";
        addButton.name = "List["+fCount+"]";
        addButton.setAttribute("class", "normal");
        addButton.style.width = "250px";
        addButton.onkeydown = function(){
            blur();
        };
        var o2 = document.createElement("br");
        var o3 = document.createElement("br");
        fObject.appendChild(addButton);
        fObject.appendChild(o2);
        fObject.appendChild(o3);
        fCount++;
      }
  }
</script>
Sign up to request clarification or add additional context in comments.

Comments

2

You are confusing your terminologies here slightly - JavaScript itself doesn't show any UI, it is the HTML (or the XUL or something completely different) which shows the UI.

Assuming that you are talking about html, the way to create a drop down list is simply to write the corresponding html for the drop down list to wherever it is in the document that you wish the drop down list to be placed, for example:

<div id="myDiv"></div>
<script type="text/javascript">
    myDiv = document.getElementById("myDiv");
    myDiv.innerHtml = "<select><option>a</option><option>b</option><option>c</option><option>d</option>";
</script>

Most likely you will be dynamically writing the HTML based on an existing list of items, but I don't want to go into that in too much detail because that will completely depend on your specific requirements and because jQuery will make this a lot easier.

EDIT: Typo fix in variable names.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.