[Javascript] Eval?
Cutter Bl
cutterbl at hotmail.com
Thu Jul 18 12:41:30 CDT 2002
You don't need the plus signs. Try it like this:
function deleteBond(id,formName){
if (confirm('Are you sure you want to delete this record?')){
formName.ID.value = id;
formName.action.value = 'delete';
formName.submit();
}
}
Cutter
Falcon Knives
----Original Message Follows----
From: "Andrew Peterson" <webmaster at mail.ioc.state.il.us>
Reply-To: javascript at LaTech.edu
To: <Javascript at LaTech.edu>
Subject: [Javascript] Eval?
Date: Thu, 18 Jul 2002 12:23:14 -0500
Hi,
I have multiple forms on one html page, and am trying to pass in a form name
into a javascript function so that I can tell the javascript function what
form to run against, but I cannot properly assign a variable to it due to my
lack of knowledge in this area. The variable that I am having trouble with
is 'formName' The following code returns the error "ID is null or not an
object" or something similar:
html:
<!-- here I am trying to pass in the variable -->
<a href="javascript: deleteBond(#ID#,'myForm');">Del</a>
javascript:
function deleteBond(id,formName){
if (confirm('Are you sure you want to delete this record?')){
/* The code blows up on the line below when trying to evaluate (ooooh wait
do I have to evaluate??? maybe I'm on to something...) the formName
attribute */
window.document.+formName+.ID.value = id;
window.document.+formName+.action.value = 'delete';
window.document.+formName+.submit();
}
}
This code works fine, however:
<a href="javascript: deleteBond1(#ID#);">Del</a>
function deleteBond1(id){
if (confirm('Are you sure you want to delete this record?')){
window.document.form1.ID.value = id;
window.document.form1.action.value = 'delete';
window.document.form1.submit();
}
}
I just want to prevent having to write a javascript function for every form
I have in the html page simply because I cannot figure out how to pass in
the form name. Any help is greatly appreciated. Meanwhile, I'm going to work
with the eval() function to see what I come up with
Thanks in advance,
Andrew
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
More information about the Javascript
mailing list