javascript - Option Select JQuery Event from Add Input -


I am trying to write a script that selects option with a code: HTML here Is:

  & lt; Div id = "rule" & gt; & Lt ;! - jscript / js / - & gt; Is controlled by addRule.js in & Lt; Div id = "add-rule" & gt; & Lt; P & gt; & Lt; / P & gt; & Lt ;! - left empty to clear script - & gt; & Lt; A href = "#" class = "add-rule" id = "add" & gt; + Included rule & lt; / A & gt; & Lt; / Div & gt;  

When you press + Rule :

  $ (function () {var) then my javascript will actually contain new fields Will add scntDiv = $ ('# rule'); Var I = $ ('# rule p'). Shape (); $ ('# Add') Live ('click', function () {var inputRule = '& lt; P & gt; User: & lt; br & gt; & lt; select name = "user_relev_' + i +'" & gt; + '& Lt; option value = "registered" & gt; registered & lt; / option & gt;' + '& lt; option value = "purchased" & gt; purchased & lt; / option & gt;' + & Lt; option value = "created" & gt; created & lt; / option & gt; & lt; / select & gt; '+' & lt; id = "time_select _ '+ i +' class =" Time (Option) & lt; / option & gt; '+' & lt; Option Value = "- Option - '+ i +'" name = "Time_Sect_' + i + '" & gt;' + '& lt ; Option value = "yes" yes "& gt; all (not included) & lt; / option & gt; '+' & lt; option Value = "first" & gt; first & lt; / option & gt; '+' & lt; option value = "after" & gt; after & lt; / option & gt; '+' & lt; option value = & Quot; option & gt; & lt; / select & gt; '+' & lt; input type = "date" name = "start_data _ '+ i +' id" between id = "biten" and gt; = "Begin_date _ '+ i +' class =" campaign-input "> 
" + "& lt; input type =" date "name =" and_data_ "+" + "id =" End_data _'+ + + + "class =" campaign-input "& gt; & Lt; Br> + '& Lt; A href = "#" class = "delete-" & gt; Remove & lt; / A & gt; '; $ (INPUT rule) .appendTo (scntDiv); $ ('# BEGIN_DATE _' + i) .hide (); $ ('# End_date _' + i) .hide (); $ ('# Time_select _' + i) .change (function () {if ($ (this) .val () == 'BEFORE' || $ (this) .val () == 'AFTER') {$ ('#begin_date _' + i) Show (); console.log ($ ('# begin_date _' + i) Show ());}}); I ++; return false; }); $ ('. Delete-rule'). Live ('click', function () {if (i & gt; 1) {$ (this) .parents ('p'). Remove (); i--;} return false;});

Edit I decided to make it easy and just decided to hide the input and display them like ordinary animation. The only problem now is, i counts off 1. When it seems that getting rid of start_date_1 then it looks for start_date_2 (which is obviously not there).

The problem occurs when you change the delete button, Means to be inserted, which means $ (this) .parents ('p') will not return anything, and nothing will be removed.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -