'Form' and 'Div' - unable to divide page using DIV Tag

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patelxxx
    New Member
    • May 2007
    • 135

    'Form' and 'Div' - unable to divide page using DIV Tag

    I'm trying to use the DIV tag instead of the FORM tag which I'm currently using in my code to create a 'drop down list'. But I'm getting the ERROR: 'document.drop_ list.locationID ' is null or not an object.

    How can I make the FORM tag to a DIV tag in the code below? What other changes do I need to do?:
    [code=javascript]
    <html>
    <head>

    <script>
    function addOption(selec tbox,text,value )
    {
    var optn = document.create Element("OPTION ");
    optn.text = text;
    optn.value = value;
    selectbox.optio ns.add(optn);
    }
    </script>


    </head>



    <body onLoad="addOpti on_list()";>

    <FORM name="drop_list ">
    Location:
    <SELECT NAME id="locationID" >
    <option>--Location--</option></SELECT>
    </FORM>

    <script>
    function addOption_list( )
    {
    var locate = new Array("England" , "Wales", "Scotland", "Ireland");

    for (var i=0; i < locate.length;+ +i){

    addOption(docum ent.drop_list.l ocationID, locate[i], locate[i]);
    }
    }
    </script>
    <br></br>
    </body>
    </html>[/code]
  • vee10
    New Member
    • Oct 2006
    • 141

    #2
    Originally posted by patelxxx
    I'm trying to use the DIV tag instead of the FORM tag which I'm currently using in my code to create a 'drop down list'. But I'm getting the ERROR: 'document.drop_ list.locationID ' is null or not an object.

    How can I make the FORM tag to a DIV tag in the code below? What other changes do I need to do?:

    <html>
    <head>

    <script>
    function addOption(selec tbox,text,value )
    {
    var optn = document.create Element("OPTION ");
    optn.text = text;
    optn.value = value;
    selectbox.optio ns.add(optn);
    }
    </script>


    </head>



    <body onLoad="addOpti on_list()";>

    <FORM name="drop_list ">
    Location:
    <SELECT NAME id="locationID" >
    <option>--Location--</option></SELECT>
    </FORM>

    <script>
    function addOption_list( )
    {
    var locate = new Array("England" , "Wales", "Scotland", "Ireland");

    for (var i=0; i < locate.length;+ +i){

    addOption(docum ent.drop_list.l ocationID, locate[i], locate[i]);
    }
    }
    </script>
    <br></br>
    </body>
    </html>

    hi ,

    i have executed this code but i did not get any error and the values in dropdown list are present.

    Comment

    • epots9
      Recognized Expert Top Contributor
      • May 2007
      • 1352

      #3
      Originally posted by patelxxx
      I'm trying to use the DIV tag instead of the FORM tag which I'm currently using in my code to create a 'drop down list'. But I'm getting the ERROR: 'document.drop_ list.locationID ' is null or not an object.

      How can I make the FORM tag to a DIV tag in the code below? What other changes do I need to do?:

      <html>
      <head>

      <script>
      function addOption(selec tbox,text,value )
      {
      var optn = document.create Element("OPTION ");
      optn.text = text;
      optn.value = value;
      selectbox.optio ns.add(optn);
      }
      </script>


      </head>



      <body onLoad="addOpti on_list()";>

      <FORM name="drop_list ">
      Location:
      <SELECT NAME id="locationID" >
      <option>--Location--</option></SELECT>
      </FORM>

      <script>
      function addOption_list( )
      {
      var locate = new Array("England" , "Wales", "Scotland", "Ireland");

      for (var i=0; i < locate.length;+ +i){

      addOption(docum ent.drop_list.l ocationID, locate[i], locate[i]);
      }
      }
      </script>
      <br></br>
      </body>
      </html>
      since your not doing anything with the form tag, why not hardcode it in?
      [html]
      <div name="drop_list ">
      Location:
      <SELECT NAME id="locationID" >
      <option>--Location--</option></SELECT>
      </div>
      [/html]

      but without the form tag u will be able to pass the results to a server-side script...unless u use AJAX.

      good luck

      Comment

      • epots9
        Recognized Expert Top Contributor
        • May 2007
        • 1352

        #4
        u will also need to change this as well
        [code=javascript]
        addOption(docum ent.getElementB yId("locationID "), locate[i], locate[i]);
        [/code]

        Comment

        • patelxxx
          New Member
          • May 2007
          • 135

          #5
          Thank guys for your help, you answered my question!!!

          Thanks again.

          Comment

          Working...