PDA

View Full Version : autopopulate text input from textarea?


rockdoc
02-20-2008, 12:03 AM
To save time inputting data in to a web form, is it possible to copy and paste alphanumeric data (e.g. from excel) into a text area and have that auto populate the individual text fields?

Can the order of items in the text area be linked to the order of fields in the form?
Example

<form>
<input type="text" name="Subject">
<input type="text" name="Task">
<input type="text" name="Weight">

<TEXTAREA NAME="Auto Populate">
Math
Algebra Test
25%
</TEXTAREA>

<input type="submit" value="Autopopulate">

</form>

_Aerospace_Eng_
02-20-2008, 01:45 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script type="text/javascript">
function fillBoxes()
{
var data = document.forms[0].autopopulate.value.split(/\n|\r\n/i);
document.forms[0].Subject.value = data[0];
document.forms[0].Task.value = data[1];
document.forms[0].Weight.value = data[2];
}
</script>
</head>

<body>
<form onsubmit="return fillBoxes()">
<input type="text" name="Subject">
<input type="text" name="Task">
<input type="text" name="Weight">
<textarea name="autopopulate">
Math
Algebra Test
25%
</textarea>
<input type="submit" value="Autopopulate">
</form>
</body>
</html>

rockdoc
02-20-2008, 10:43 AM
Thankyou very much _Aerospace_Eng_


Ok, split, put into an array, send to form fields ... nice one :thumbsup:

Much appreciated.