I am trying to create a generic data prompt for my forms.
Basically, I want a prompt function that takes as arguments a form name, a field name, and a message to display on the prompt. This way I can simply call the function with some arguments in the following way:
<a href=http://www.webdeveloper.com/forum/archive/index.php/"javascript:chpw.id.value=12345;gen_prompt('Enter new password','chpw','newpw');gen_prompt('Confirm new password','chpw','conpw');chpw.submit();">Change Password</a>
Where chpw is the name of the form and newpw and conpw are the names of two hidden fields within that form. My current function looks like this:
function gen_prompt(msg,frm,fld)
{
ans = prompt(msg,\"\");
document.frm.fld.value=ans;
}
The problem with this is that javascript does not interpolate the variables into the document string. It tries to write the value to a literal form called frm and a literal field called fld. Is there anyway to cause the variables to be interpolated correctly? Is there another way to do this?
Thanks.
--Jason
Basically, I want a prompt function that takes as arguments a form name, a field name, and a message to display on the prompt. This way I can simply call the function with some arguments in the following way:
<a href=http://www.webdeveloper.com/forum/archive/index.php/"javascript:chpw.id.value=12345;gen_prompt('Enter new password','chpw','newpw');gen_prompt('Confirm new password','chpw','conpw');chpw.submit();">Change Password</a>
Where chpw is the name of the form and newpw and conpw are the names of two hidden fields within that form. My current function looks like this:
function gen_prompt(msg,frm,fld)
{
ans = prompt(msg,\"\");
document.frm.fld.value=ans;
}
The problem with this is that javascript does not interpolate the variables into the document string. It tries to write the value to a literal form called frm and a literal field called fld. Is there anyway to cause the variables to be interpolated correctly? Is there another way to do this?
Thanks.
--Jason