Hirschsprung disea
Influence of the n
A high school stud
Safety The Office
[Influence of high
Q: Difference bet
You don’t have to
Category: Blogging
Souls on Ice Soul
// (C) Copyright

This page contains
/* * This file is
Pope Francis said
The present invent
Samsung has always
Lack of associatio
As of Saturday, Ja
It’s that time of
Q: What is the or
Q: In which order
Q: How to create dynamic text boxes in PHP? Is it possible to create dynamic textboxes? I would like to create an input text box based on what the user enters in a previous text box. Say the user enters 3 in the first text box and it creates 3 textboxes based on it. Or, how can I do something like creating a dynamic text box. The reason why I am trying to do that is because the number of textboxes will be different for each user. So, how can i make the numbers of textboxes dynamic? For example: textbox one : type number var i=1; var txtbox2=""; $("document").ready(function(){ $('#box1').live("keyup", function() { txtbox2 = txtbox2 + " #" + i++; var idname = idname + txtbox2; $("#ok2").click(function() { alert(idname); }); }); }); A: Something like this? $("#txtBox").live("keyup", function() { $(this).after(""); }); A: Yes, by building HTML using JavaScript you can create input elements on the fly and add them to the page without reloading it. It's fairly simple, actually. Just use a string to generate a series of elements you'd like to appear on the page and then either inject it into an element that you can access via jQuery or attach an event handler that sets the text for these newly created input fields so that you can read the value they contain. Example // create HTML from the string var div = document.createElement('div'); var input = document.createElement('input'); input.type = 'text'; var i = 0; while(i < 3) { input.name = 'Input' + i; input.value = 'New Input ' + i; input.style = 'display:none;'; // get an input field (not sure how you'd get the button, you know) var inputText = document.getElementById('Input' + i); // then append the input element to the div and set its value div.appendChild(input); input.value = 'New Input ' + i;  // set the name to what's in the value input.name = inputText.value; i++; } // if you want the user to be able to enter something, you'd have to add code for // text/number/number/textboxes/etc. Edit: Oh yeah, I nearly forgot, how to access them: // iterate through the text input fields and log them for(var i = 0; i < textFields.length; i++) { console.log(textFields[i].value); } I didn't add support for text boxes and dropdowns. I'll have a go at it and update this answer when I'm done. A: yes, you can do this $('#box1').live("keyup", function() { //make your text box based on the number in the other box $('#box1').after(''); }); just check the link for more info http://api.jquery.com/live/ if you are using jquery you can make a function to add many text boxes like $(document).ready(function() { var count = 0; $('#box').live("keyup", function() { count++; $('#boxes').append('

'); }); }); http://api.jquery.com/append/ for making dynamic text boxes to insert you will get some thing like this $('#box1').after(''); http://api.jquery.com/after/ for more information please visit this link. http://api.jquery.com/append/ http://api.jquery.com/keyup/ http://api.jquery.com/live/ http://api.jquery.com/load/ http://api.jquery.com/each/ http://api.jquery.com/before/ http://api.jquery.com/keydown/ http://api.jquery.com/each/