lindm
12-01-2007, 08:06 AM
Trying to accomplish this:
I have a form with many form elements. I want the value of the input fields that end with CY be transferred to the input fields that end with PY. So form input with name xxxCY will be moved to form input xxxPY, form input with name yyyCY will be moved to form input yyyPY, etc.
Having trouble formulating the javascript.
Example:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script language="JavaScript">
function movecytopy()
{
for(i=0; i<document.FormName.elements.length; i++)
{
NEED HELP WITH THIS PART
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="button" name="button" id="button" value="MOVE CY TO PY" onclick="movecytopy()" /></td>
<td> </td>
</tr>
<tr>
<td><input name="example1CY" type="text" id="example1CY" size="15" /></td>
<td><input name="example1PY" type="text" id="example1PY" size="15" /></td>
</tr>
<tr>
<td><input name="example2CY" type="text" id="example2CY" size="15" /></td>
<td><input name="example2PY" type="text" id="example2PY" size="15" /></td>
</tr>
<tr>
<td><input name="example3CY" type="text" id="example3CY" size="15" /></td>
<td><input name="example3PY" type="text" id="example3PY" size="15" /></td>
</tr>
<tr>
<td><input name="example4CY" type="text" id="example4CY" size="15" /></td>
<td><input name="example4PY" type="text" id="example4PY" size="15" /></td>
</tr>
</table>
</form>
</body>
</html>
I have a form with many form elements. I want the value of the input fields that end with CY be transferred to the input fields that end with PY. So form input with name xxxCY will be moved to form input xxxPY, form input with name yyyCY will be moved to form input yyyPY, etc.
Having trouble formulating the javascript.
Example:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script language="JavaScript">
function movecytopy()
{
for(i=0; i<document.FormName.elements.length; i++)
{
NEED HELP WITH THIS PART
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="button" name="button" id="button" value="MOVE CY TO PY" onclick="movecytopy()" /></td>
<td> </td>
</tr>
<tr>
<td><input name="example1CY" type="text" id="example1CY" size="15" /></td>
<td><input name="example1PY" type="text" id="example1PY" size="15" /></td>
</tr>
<tr>
<td><input name="example2CY" type="text" id="example2CY" size="15" /></td>
<td><input name="example2PY" type="text" id="example2PY" size="15" /></td>
</tr>
<tr>
<td><input name="example3CY" type="text" id="example3CY" size="15" /></td>
<td><input name="example3PY" type="text" id="example3PY" size="15" /></td>
</tr>
<tr>
<td><input name="example4CY" type="text" id="example4CY" size="15" /></td>
<td><input name="example4PY" type="text" id="example4PY" size="15" /></td>
</tr>
</table>
</form>
</body>
</html>