Dec 5, 2001 #1 mtawk Programmer Nov 6, 2001 26 IQ I want to create an input (Button, or else) dynamically with Javascript code. Is there a way to do it ? Thanks
I want to create an input (Button, or else) dynamically with Javascript code. Is there a way to do it ? Thanks
Dec 5, 2001 #2 Damian13 Programmer Nov 20, 2001 18 ZA <!-- Here's some code to create controls dynamically that I found --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function createForm(number) { data = ""; inter = "'"; if (number < 16 && number > -1) { for (i=1; i <= number; i++) { if (i < 10) spaces=" "; else spaces=" "; data = data + "URL " + i + " :" + spaces + "<input type='text' size=10 name=" + inter + "url" + i + inter + "'><br>"; } if (document.layers) { document.layers.cust.document.write(data); document.layers.cust.document.close(); } else { if (document.all) { cust.innerHTML = data; } } } else { window.alert("Please select up to 15 entries." } } // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <center> <!-- <form name=counter> Number of URLs to enter: <input type=text name=number size=5 onblur="createForm(counter.number.value);"> </form> --> <br> <form name="webform"> Number of URLs to enter: <input type=text name=number size=5 onblur="createForm(this.value);"> <table border=0> <tr valign=top> <td>Name:</td> <td><input type=text size=20 name=name></td> </tr> <tr> <td colspan=2> <!-- Placeholder for dynamic form contents --> <span id=cust style="position:relative;"></span> </td> </tr> <tr valign=top> <td>Comments:</td> <td><textarea name=comments cols=45 rows=5 wrap=virtual> </textarea></td> </tr> <tr> <td></td> <td><input type=submit value="Send"></td> </tr> </table> </form> </center> <p> <center> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center> <p> Upvote 0 Downvote
<!-- Here's some code to create controls dynamically that I found --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function createForm(number) { data = ""; inter = "'"; if (number < 16 && number > -1) { for (i=1; i <= number; i++) { if (i < 10) spaces=" "; else spaces=" "; data = data + "URL " + i + " :" + spaces + "<input type='text' size=10 name=" + inter + "url" + i + inter + "'><br>"; } if (document.layers) { document.layers.cust.document.write(data); document.layers.cust.document.close(); } else { if (document.all) { cust.innerHTML = data; } } } else { window.alert("Please select up to 15 entries." } } // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <center> <!-- <form name=counter> Number of URLs to enter: <input type=text name=number size=5 onblur="createForm(counter.number.value);"> </form> --> <br> <form name="webform"> Number of URLs to enter: <input type=text name=number size=5 onblur="createForm(this.value);"> <table border=0> <tr valign=top> <td>Name:</td> <td><input type=text size=20 name=name></td> </tr> <tr> <td colspan=2> <!-- Placeholder for dynamic form contents --> <span id=cust style="position:relative;"></span> </td> </tr> <tr valign=top> <td>Comments:</td> <td><textarea name=comments cols=45 rows=5 wrap=virtual> </textarea></td> </tr> <tr> <td></td> <td><input type=submit value="Send"></td> </tr> </table> </form> </center> <p> <center> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center> <p>