RE: Re: Construct context-relative URL in Javascript?

2001-08-10 Thread devon . bowen

> I don't want the result in an a href. I want to do a POST and 
> I want to be able to set the 
> TARGET attribute for the FORM before posting as well. I want 
> to set the form's ACTION 
> attribute to that value. But I have multiple values that the 
> form's ACTION attribute might get 
> set to and so I have to do it in Javascript based on which 
> button the user clicked on.

Not sure I completely understand but it sounds like 
is what you're looking for. It rewrites a URI and writes the
output directly into your page. For example, I have in my code:

')">

So when this button is pushed, the JavaScript detail() function
is called with the correct URI for the detail_window action
passed as a parameter.

Devon




Re: Construct context-relative URL in Javascript?

2001-08-09 Thread Randall Parker

On Wed, 8 Aug 2001 17:47:22 -0500, [EMAIL PROTECTED] wrote:

>
>Did you try ?

How can that help? 

I don't want the result in an a href. I want to do a POST and I want to be able to set 
the 
TARGET attribute for the FORM before posting as well. I want to set the form's ACTION 
attribute to that value. But I have multiple values that the form's ACTION attribute 
might get 
set to and so I have to do it in Javascript based on which button the user clicked on.

The html:base looks like will calc the right absolute URL and I could create one for 
each 
button. But I'd have to make them invisible (since I don't want to the user clicking 
on them) 
and then have some way to get at their HREF attribute value.  In theory that may be 
possible using DOM calls from Javascript if I set ID values for each A HREF element. 
But 
that's limit what browser versions could be used.

So I'd rather have the values be placed in invisible controls by the server when it 
generates 
the page.







Re: Construct context-relative URL in Javascript?

2001-08-08 Thread Brian . Duchouquette


Did you try ?




   

"Randall   

Parker"  To: "[EMAIL PROTECTED]" 
<[EMAIL PROTECTED]> 
        Subject: Construct context-relative URL 
in Javascript?
   

08/08/2001 

05:23 PM   

Please 

respond to 

struts-user

   

   





I've seen Craig posted how something like
   
will get translated to
   

But I need to create a context-sensitive URL in Javascript. The reason for
this is that
there are multiple buttons on my form/page and in the action handler
function for
each button I need to set the form's action to the appropriate action for
that button
click before submitting the form.

So I think I want a way to do get at info in Javascript that is the
equivalent of what is
returned by javax.servlet.http.HttpServletRequest req.getContextPath()

So that something like this can be done in Javascript
   this.form.action = contextPath + "/graphs/fullgraph.jsp"

(or .do instead of .jsp or whatever)

So is there some way with a Struts tag to put the context path on the
generated
page using perhaps an invisible control that would be set to have the
context path as
its value? Then one could assign the invisible control's value for the the
context path
to a Javascript variable and use it in something like the code snippet
above.

I also need to do some other stuff in the Javacsript (eg set the target
attribute of the
form tag using a generated value as well). So I think I really need to use
Javascript to
do this.

Or am I approaching the problem in a way that is totally wrong?











Construct context-relative URL in Javascript?

2001-08-08 Thread Randall Parker

I've seen Craig posted how something like

will get translated to


But I need to create a context-sensitive URL in Javascript. The reason for this is 
that 
there are multiple buttons on my form/page and in the action handler function for 
each button I need to set the form's action to the appropriate action for that button 
click before submitting the form. 

So I think I want a way to do get at info in Javascript that is the equivalent of what 
is 
returned by javax.servlet.http.HttpServletRequest req.getContextPath()

So that something like this can be done in Javascript
   this.form.action = contextPath + "/graphs/fullgraph.jsp"

(or .do instead of .jsp or whatever)

So is there some way with a Struts tag to put the context path on the generated 
page using perhaps an invisible control that would be set to have the context path as 
its value? Then one could assign the invisible control's value for the the context 
path 
to a Javascript variable and use it in something like the code snippet above.

I also need to do some other stuff in the Javacsript (eg set the target attribute of 
the 
form tag using a generated value as well). So I think I really need to use Javascript 
to 
do this.

Or am I approaching the problem in a way that is totally wrong?