kellyputty
asked on
Copy the value of 1 var (input type= text) into another var (input type hidden) : Javascript
I have payment submit form for USAepay
<input type="text" name="UMname" size="25" value="[UMname]">
Gets the peron's name and correctly submits it and I can see the persons name on a report at the USAepay site.
the cgi variable UMbilllname is what is used for a recurring charge. I would like to be able to see the person's name in that report also, but I can't because the variable isn't getting set (it is a hidden ). It has been suggested that I use javascript to acquire the value in UMname and place it in UMbillname:
function myUMname()
{
if (document.getElementById)
{
var elName=document.getElement ById('UMna me');
var elBillName = document.elName.value;
}
}
</script>
</head>
<body>
<input id='UMname' type="text" name="UMname" size="25" value="[UMname]" onChange="myUMname();">
<input id='UMbilllname' type="hidden" name="UMbilllname" size="25" value="[elBillName]">
</body>
</html>
The above doesn't work and I am new to javascript, what am I doing wrong?
<input type="text" name="UMname" size="25" value="[UMname]">
Gets the peron's name and correctly submits it and I can see the persons name on a report at the USAepay site.
the cgi variable UMbilllname is what is used for a recurring charge. I would like to be able to see the person's name in that report also, but I can't because the variable isn't getting set (it is a hidden ). It has been suggested that I use javascript to acquire the value in UMname and place it in UMbillname:
function myUMname()
{
if (document.getElementById)
{
var elName=document.getElement
var elBillName = document.elName.value;
}
}
</script>
</head>
<body>
<input id='UMname' type="text" name="UMname" size="25" value="[UMname]" onChange="myUMname();">
<input id='UMbilllname' type="hidden" name="UMbilllname" size="25" value="[elBillName]">
</body>
</html>
The above doesn't work and I am new to javascript, what am I doing wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To use amit_g's solution, which is also perfectly fine, just make sure you enclose your <input> fields with <form> tags.
var elBillName = document.elName.value;
you need to have
var elBillName = document.getElementById('U
elBillName.value = elName.value;
However, I would recommend doing this on the server-side, if possible.