javascriptleafletleaflet-draw

How do I use <select> in inline js?


In my leaflet map I want the user to input some information about a place. This currently looks like this:

var formPopup= L.popup();
      var content = '<span><b>Name</b></span><br/><input id="shapeName" type="text"/><br/><br/>' +
                    '<select id="shapeType" option value="House" option value="Rock"></select><br/><br/>'+
                    '<input type="button" id="okBtn" value="Save" onclick="saveIdIW()"/>';

Now, I know the way I try to use option and value here is quite wrong. Unfortunately, my google-fu failed me in finding how to do it correctly.


Solution

  • You wrong in option tag syntax:

     var content = '<span><b>Name</b></span><br/><input id="shapeName" type="text"/><br/><br/>' +
                    '<select id="shapeType"><option value="House">House</option><option value="Rock">Rock</option></select><br/><br/>'+
                    '<input type="button" id="okBtn" value="Save" onclick="saveIdIW()"/>';