Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i create a button with JS

Status
Not open for further replies.

mtawk

Programmer
Nov 6, 2001
26
0
0
IQ
I want to create an input (Button, or else) dynamically with Javascript code.
Is there a way to do it ?
Thanks
 
<!--
Here's some code to create controls dynamically that I found
-->

<HEAD>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
function createForm(number) {
data = &quot;&quot;;
inter = &quot;'&quot;;

if (number < 16 && number > -1) {
for (i=1; i <= number; i++) {
if (i < 10) spaces=&quot; &quot;;
else spaces=&quot; &quot;;
data = data + &quot;URL &quot; + i + &quot; :&quot; + spaces + &quot;<input type='text' size=10 name=&quot; + inter + &quot;url&quot; + i + inter + &quot;'><br>&quot;;
}
if (document.layers) {
document.layers.cust.document.write(data);
document.layers.cust.document.close();
} else {
if (document.all) {
cust.innerHTML = data;
}
}
} else {
window.alert(&quot;Please select up to 15 entries.&quot;);
}
}

// 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=&quot;createForm(counter.number.value);&quot;>
</form>
-->
<br>
<form name=&quot;webform&quot;>
Number of URLs to enter:
<input type=text name=number size=5 onblur=&quot;createForm(this.value);&quot;>
<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=&quot;position:relative;&quot;></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=&quot;Send&quot;></td>
</tr>
</table>
</form>
</center>

<p>
<center>
<font face=&quot;arial, helvetica&quot; size=&quot;-2&quot;>Free JavaScripts provided<br>
by <a href=&quot; JavaScript Source</a></font>
</center>
<p>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top