-
Jul 2nd, 2015, 02:10 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Adding Events With Dynamic HTML Control
Good day,
I was able to make the adding of html textbox control working perfectly.
So here's my code for adding textboxes.
Code:
var elementCounter = 2;
// NEW BOOK TEXTBOX.
var newBookTextbox = $(document.createElement('div'))
.attr("class", "col-md-2");
newBookTextbox.after().html('<input type="text" id="Book' + requestCounter + '" class="form-control width-skills" name="Book' + requestCounter + '" style="font-size:12px" maxlength="2">');
newBookTextbox.appendTo(multiRequestDiv);
// NEW TITLE TEXTBOX.
var newTitleTextbox = $(document.createElement('div'))
.attr("class", "col-md-2");
newTitleTextbox.after().html('<input type="text" id="Title' + requestCounter + '" class="form-control width-skills" name="Title' + requestCounter + '" style="font-size:12px">');
newTitleTextbox.appendTo(multiRequestDiv);
As you can see I'm creating two textboxes under the name of "Book" and "Title". Now what I want is to append an OnBlur event upon creating of new instance of textbox "Book" only. So everytime they type on "Book(x)" an alert will be prompted.
Can anyone help me about this.. Thank you
-
Jul 2nd, 2015, 02:59 AM
#2
Thread Starter
Fanatic Member
Re: Adding Events With Dynamic HTML Control
I got it
Code:
// NEW BOOK TEXTBOX.
var NewBookTextbox = document.createElement('input');
NewBookTextbox.id = "Book";
NewBookTextbox.name = "Book";
NewBookTextbox.className = "form-control";
NewBookTextbox.style.cssText = "font-size: 12px";
NewBookTextbox.onblur = function () {
<!-- Method Here -->
};
As you can see I change how I create a dynamic control from using a "$(document.createElement)" to plain, so that I have an access to the function of blur in native way.
Last edited by aNubies; Jul 15th, 2015 at 05:00 AM.
-
Jul 2nd, 2015, 07:07 AM
#3
Re: [RESOLVED] Adding Events With Dynamic HTML Control
If you were able to solve your problem, you should post the code you used to fix it here. That way, if someone is having a similar issue, when they search they don't just find a "I got it" post without a solution.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|