Click to See Complete Forum and Search --> : Javascript Question


Boumxyz2
July 30th, 2002, 10:29 AM
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


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 ?..

Surrendermonkey
July 30th, 2002, 10:39 AM
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.

anupam kant
July 30th, 2002, 11:28 PM
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();
}

Boumxyz2
July 31st, 2002, 10:41 AM
I found a solution and it's even simpler

function formSubmit(FormToSend)
{
document.all(FormToSend).submit();
}