html - Why when i click selectbox, javascript create new div? -


I need JavaScript function to create new incremental divs by clicking on the image! It works !! But when I click on the selected option, I can not choose any option and JavaScript always creates new devices. Why?

  & lt; Script type = "text / javascript" & gt; Var i = 1; Var p = 1; Function Duplicate () {var Basic = document.getElementById ('Cell'); Var subdiv = document.getElementById ('subroom'); Var clone = subDiv.cloneNode (true); // "dark" clone // document.getElementsByName ("st"). InnerHTML = "cell" +++ p; Clone.setupbrit ('class', 'self-room self-cell -' +++ i); // Only an id / subDiv.setAttribute ('class', 'self-cell self-cell -' +++ i) can be an element with; // clone.setAttribute ('class', "sw-room sw-room -" +++ i); // Only one ID can be an element with clone. Click on = Duplicate; // event handler is not crawled; var find = document.getElementById ('fff'); Original.appendChild (clone, find.nextSibling); } & Lt; / Script & gt;  

I need my script onclick on an image (create Particle CSS Sprite)

  div id = "searchbox" Class = "border-radius" & gt; & Lt; Span class = "searchbox-elem" & gt; & Lt; Strong id = "sb-title" & gt; Check Availability & lt; / Strong> & Lt; Input id = "city" type = "text" title = "where do you want to go?" Placeholder = "your destination ..." auto-integer = "off" value = "" alt = "" name = "city" tabindex = "1" & gt; & Lt; / Span & gt; & Lt; Span class = "searchbox-elem" & gt; & Lt; Span id = "searchbox_from" square = "sb-label" & gt; & Lt; / Span & gt; & Lt; Input id = "checkin" class = "hasdatepicker" type = "text" maxlength = "20" placeholder = "check-in date ..." autocomplete = "off" value = "alt =" dd / mm / yyyy " Name = "checkin" tabindex = "2" & gt; & Lt; / Span & gt; & Lt; Span class = "searchbox-elem" & gt; & Lt; Span id = "searchbox_to" square = "sb-label" & gt; & Lt; / Span & gt; & Lt; Input id = "checkout" class = "hasdatepicker" type = "text" maxlength = "20" placeholder = "checkout date ..." autocomplete = "off" value = "alt =" dd / mm / yyyy "name = "Checkout" tabindex = "3" & gt; & Lt; / Span & gt; & Lt; Div id = "room" class = "sw-rooms-list" & gt; & Lt; Span class = "searchbox-elem" & gt; & Lt; Div id = "subroom" class = "sw-room sw-room-1" & gt; & Lt; Div name = "st" class = "searchbox_room_count" & gt; Room 1 & lt; / Div & gt; & Lt; Div class = "pval_container" & gt; & Lt; Div class = "self-placeholder" & gt; 2 Adult & lt; / Div & gt; & Lt; Select class = "pval pval_r1" name = "pval_r1" & gt; & Lt; Option value = "1" & gt; 1 adult & lt; / Options & gt; & Lt; Option selected = "selected" value = "2" & gt; 2 Adult & lt; / Options & gt; & Lt; Option value = "3" & gt; 3 & lt; / Options & gt; & Lt; Option value = "4" & gt; 4 & lt; / Options & gt; & Lt; Option value = "5" & gt; 5 & ​​lt; / Options & gt; & Lt; Option value = "6" & gt; 6 & lt; / Options & gt; & Lt; Option value = "7" & gt; 7 & lt; / Options & gt; & Lt; Option value = "8" & gt; 8 & lt; / Options & gt; & Lt; Option value = "9" & gt; 9 & lt; / Options & gt; & Lt; Option value = "10" & gt; 10 & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; Div class = "cval_container" & gt; & Lt; Div class = "self-placeholder" & gt; 0 children & lt; / Div & gt; & Lt; Select class = "cval cval_r1" name = "cval_r1" & gt; & Lt; Option selected = "selected" value = "0" & ​​gt; 0 & lt; / Options & gt; & Lt; Option value = "1" & gt; 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 & lt; / Options & gt; & Lt; Option value = "3" & gt; 3 & lt; / Options & gt; & Lt; Option value = "4" & gt; 4 & lt; / Options & gt; & Lt; Option value = "5" & gt; 5 & ​​lt; / Options & gt; & Lt; Option value = "6" & gt; 6 & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Span & gt; & Lt; / Div & gt; & Lt; Div id = "aaa" & gt; & Lt; An id = "add" href = "#" class = "sloglo_model" style = "display: block;" Onclick = "return duplicate ()" & gt; & Lt; / A & gt; & Lt; Span class = "add-day" & gt; Add 1 more & lt; / Span & gt; & Lt; / Div & gt; & Lt; Div id = "fff" class = "searchbox-elem" & gt; & Lt; Input id = "search" class = "button btn-blue" type = "submit" range = "0" value = "FIND HOTEL" title = "" onblur = "0" & ​​gt; & Lt; / Div & gt; & Lt; / Div & gt; Cloning an element with the ID, thus creating two elements with the same ID.  

. It is not allowed

Perhaps you can mark elements with classes instead?


Comments