-
Javascript Question
Hi all,
I'm working on ASP pages and I need some javascript to be done. I was thinking you might help me out with this :
here's the problem
I dynamically add forms to my html page ( search results ) and I need to send the form when the user clicks on the link of the form.
here's the code I've been working around so far
Code:
function FormSubmit(FormToSend)
{
var Str;
Str = "Document."+FormToSend;
SendingForm = eval(Str);
SendingForm.submit();
}
I'm using a counter for the form name. and send it to the FormSubmit Function. Well as you can expect the eval line doesn't work. it says it expects a ";" and none is missing. Is there a way to get a reference to an object dynamically ?..
-
try this...
From where are you calling the FormSubmit function?
Depending on this, you could use
onclick="javascript:FormSubmit();" and examine the window.event.srcElement to determine the object which was clicked.
-
The only problem with this function is "Document"
in this expression
Str = "Document."+FormToSend;
try this and it will work:
Str = "document."+FormToSend;
(note that small 'd' in 'document' here)
Now the function will be:
function FormSubmit(FormToSend)
{
var Str;
Str = "document."+FormToSend;
SendingForm = eval(Str);
SendingForm.submit();
}
-
I found a solution and it's even simpler
function formSubmit(FormToSend)
{
document.all(FormToSend).submit();
}