Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-03-2013, 07:55 AM   PM User | #1
love4js
New to the CF scene

 
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
love4js is an unknown quantity at this point
javascript code

12 hours, 2 minutes ago|LINK

I have 1 text box name: createcontrolbox:...........................................

quantity:........................................................

one button .........create.....................

i have to enter suppose: text ........

5 then

click button

it should show me 5 text box.......should be created. need help

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script language="javascript" type="text/javascript">
function create() {

var res1 = document.getElementById("Text1");
var res = document.createElement("Text1");
res.tagName = "text";
var res2 = document.getElementById("Text2");
res.value = "Text2";
alert(res);
}


</script>
</head>
<body>
<table>
<tr>
<td>
<label for="ctrlname"> Createcontrol*</label></td>
<td><input type="text" id ="Text1" name="Createcontrol" maxlength="50" size="30"/></td>
</tr>
<tr>
<td><label for="quantity"> quantity*</label></td>
<td><input type="text" id ="Text2" name="quantity" maxlength="50" size="30"/></td>
</tr>
<tr>
<td><input type="button" id ="btncr" value= "create" onclick="create()"/></td>

</tr>





</table>

</body>
</html>
love4js is offline   Reply With Quote
Old 03-03-2013, 01:52 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,376
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
You don't tell us where to put the text box or what to put in it.
I took the language="javascript" out of your script tag, it's not needed.
I added a second set of td's to the last row of the table as per table rules(?)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function create() {
	var box = document.createElement("input");
	document.body.appendChild(box);
}
</script>
</head>

<body>
<table>
<tr>
<td><label for="ctrlname"> Createcontrol*</label></td>
<td><input type="text" id ="Text1" name="Createcontrol" maxlength="50" size="30"/></td>
</tr>

<tr>
<td><label for="quantity"> quantity*</label></td>
<td><input type="text" id ="Text2" name="quantity" maxlength="50" size="30"/></td>
</tr>

<tr>
<td><input type="button" id ="btncr" value= "create" onclick="create()"/></td>
<td></td>
</tr>
</table>
</body>
</html>
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:28 AM.


Advertisement
Log in to turn off these ads.