Click to See Complete Forum and Search --> : Can you get target URL in onSubmit?


JSchwarz
09-29-2003, 08:58 AM
How can I get the target URL while in the onSubmit event?

Because of the ancient and bass ackwards development tool I'm using, I have no control over certain parts of the form sent to the browser. But I want to know which link was clicked, so I can do different things in the onSubmit. But I can't find out what object or property has the target URL (if any). Anyone know?

Thanks,
Jeff

Khalid Ali
09-29-2003, 09:16 AM
you will need to write some code..

1. capture events at document level
2. from the event object
get the srcElement(IE) or target(NS)
this will return the element which was clicked on

requestcode
09-29-2003, 09:28 AM
Is this what you are looking for:
<html>
<head>
<title>Which URL</title>
<script language="javascript">
function doAlert(obj)
{
alert(obj.id)
}
</script>
</head>
<body>
<a href="#" id="link1" onClick="doAlert(this)">Click Me</a><br>
<a href="#" id="link2" onClick="doAlert(this)">Click Me</a>
</body>
</html>

JSchwarz
09-29-2003, 09:47 AM
Thanks both for your response.

Kahlid, I'm looking into how to capture form events. It looks like the onSubmit is executed before the form's onClick (where I assume I would catch the event).

requestcode, you have the general idea, except that I cannot code the call to doAlert().

Here is the code that is generated, which I can't change (btw, this is Lotus Domino, if you're curious):<INPUT TYPE=radio NAME="Sref" VALUE="1" TITLE="Solicitation Reference Type" onClick="_doClick('$Refresh', this, '_self', '#_RefreshKW_Sref')">Section
<INPUT TYPE=radio NAME="Sref" VALUE="2" TITLE="Solicitation Reference Type" onClick="_doClick('$Refresh', this, '_self', '#_RefreshKW_Sref')">Attachment
<INPUT TYPE=radio NAME="Sref" VALUE="3" TITLE="Solicitation Reference Type" onClick="_doClick('$Refresh', this, '_self', '#_RefreshKW_Sref')">Other</FONT></TD></TR>
Here is the relevant portion of _doClick() (which I also can't change):function _doClick(v, o, t, h) {
var form = document._frmQuestion;
if (form.onsubmit) {
var retVal = form.onsubmit();
if (typeof retVal == "boolean" && retVal == false)
return false;
}
}
As you can see, _doClick() calls onSubmit by itself. If I could access the variable 'v', I could program a return true when 'v' equals "$Refresh". But I can't figure out how to access it.

Thanks for your help.
Jeff

JSchwarz
09-29-2003, 11:08 AM
Khalid, is target the right object in NN? I can't find it documented.