View Full Version : script to create textboxes
elite86
02-01-2008, 09:28 AM
im looking for a script that will create a certain number of textboxes according to the value entered into a specific text box.
i.e. value of 10 entered into a textbox, user clicks next, 10 text boxes are on the next page with labels next to them such as name1, name 2... etc.
number can range from 1 to 40 maximum.
cheers.
codeexploiter
02-01-2008, 02:35 PM
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>An XHTML 1.0 Strict standard template</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<style type="text/css">
</style>
<script type="text/javascript">
function createTextBoxes(){
if(parseInt(document.getElementById('num').value) > 40 || parseInt(document.getElementById('num').value) < 1){
alert('invalid number use number between 1 and 40')
return;
}
document.getElementById('inp').style.display = 'none';
for(var i = 0; i < parseInt(document.getElementById('num').value); i++){
var input = document.createElement('input');
var span = document.createElement('span');
span.appendChild(document.createTextNode('name '+ i));
var br = document.createElement('br');
input.type='text';
input.name='text'+i;
input.id='text'+i;
document.getElementById('tb').appendChild(span);
document.getElementById('tb').appendChild(input);
document.getElementById('tb').appendChild(br);
}
}
</script>
</head>
<body>
<form name="f1">
<div id="inp">
<label>No of Textbox</label><input type="text" id="num" name='num' /><br/>
<input type="button" value="Create Textboxes" onclick="javascript: createTextBoxes();"/>
</div>
<div id="tb">
</div>
</form>
</body>
</html>
Check the above code I've done it quickly so haven't done the validation much but the core functionality works correctly.
sheraz79
09-13-2008, 12:44 AM
Hi There,
how are you.
I created a order form using front page 2002.simply using text boxes.
it worked well.this form is sent to email ,not to database.
but the problem is ,the form is too long.
I like to have button where user can click and text box can appear. Instead of having so many text boxes in my order form.
Thank you .
:confused:
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.