Link to home
Start Free TrialLog in
Avatar of snocross
snocross

asked on

Javascript Question

Please see my example form and click 'Pick' above the first field.  A javascript window pops up.  You choose a word and press 'Create Request'.

What I would like to happen is from that point compose a new form and pass a value to the new form in the URL.  How can I pass the selected value to the URL in the new window?

Thanks!

-Snocross
Avatar of snocross
snocross

ASKER

In the popup window use the window.opener.location object, like this

<input type=button onclick="window.opener.location.replace('http://www.yahoo.com&field=1')">

and use query_string_decoded to capture the parameters.

~Hemanth



Sno,

can you please run catalog task on domino2.wwow.com/Wwow so I can see actual db settings <|;-)

Please zip and send me your bachwebworks/protips.nsf to: zp@worldonline.de
(or send me only your email, so I can contact you)

So long,
zvonko
allow me to repeat your question Sno;

you would like, when the user presses the button: [CreateRequest]
on the "ChooseKeyword" form, than it should not call the JavaScript function "addToList", but close the "ChooseKeyword" form and open a newone form (lets name it "RequestForm") and pass to this requestform the value user picked up in "ChooseKeyword" form.

Is this correct so far?
...untill now "addToList" writes back to the parent calling "Document" form the selected value (by JavaScript methods); so why do you like to open a third (the "RequestForm") form?
Heman, I will have to look into that.

Yes Zvonko, that's exactly what I want to do.

The reason I want to open a third is because what I'm trying to do is have a QueryOpen agent fill in the values on the 3rd document based on a key that is passed in the URL.  If I pass the value back to the original form, the QueryOpen agent does not get executed.  So I'm eventually going to skip the first document and go right to the ChooseKeyword form, pick a value, then create the new form and populate the values.

Thanks

-Snocross
OK Sno,

you do not need any WebQueryOpen agent to get an agent executed to refesh or recalculate the form.

So, how about this scenario:

1.) User opens "Document" form.
2.) User clicks on "Pick" link.
3.) In a new window opens  the "ChooseKeyword" form.
4.) User selects in this form the keyword and press [Enter] key or a [Request] button.
5.) As an action in this  "ChooseKeyword" form runs a JavaScript function.
6.) JavaScript function copies the keyword to the receiver field in "Document" form.
7.) The JavaScript function trigers a button on the "Document" form. Behind the button is an agent.
(and here comes the supertrooper trick!!! this button has not even to be visible on the form. Below is the description how to ahive this)
8.) The agent does the form recalculation and request creation.
9.) The above JavaScript function closes the "ChooseKeyword" form.

And here how to make this button to triger the agent and be invisible:
1.) Create a subform containing only one button with this two formulas:
@Command([ViewRefreshFields]);
@Command([ToolsRunMacro]; "CheckAndMakeRequest")
2.) Insert this subform at first position into "Document" form.
3.) Open the "Document" form in web browser and save the HTML source code as text.
4.) In this HTML code is a JavaScript action to triger the button (you need it).
5) Remove the subform from the "Document" form.

And here comes the supertrooper trick: the JavaScript button triger code can now be used from any JavaScript function or html event call. Even better: you can now use this line of code on forms that never have pasted this subform. You only are not allowed to edit the subform, but replication of the subform design is not a problem.

I have used this trick in R5, but I assume that R4.6 has to work the same (I have not checked this).

...and do not forget to increase the points for this question to max and give me an A <|;-)

If you have problems implementhing this, I will try to support you.

Good luck,
zvonko
That sounds very cool but my client does not want to see the form at all until the user has chosen a value from the "ChooseKeyword" form.  He wants to start from FORM A, click a button that presents the "ChooseKeyword" form B, and then is brought to a NEW form C.  He doesn't care about FORM A.

-Snocross
oh ****!
So, domino2.wwow.com/Wwow is not your server?
ASKER CERTIFIED SOLUTION
Avatar of zvonko
zvonko

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, domino2.wwow.com is my server.

Ok, that looks like what I need... just one question... when the request form opens in a new window will the address bar etc be visible (you know where you type the URL in)?  Just wondering because I noticed on the "ChooseKeyword" window there is no address bar and no BACK button etc.  This is perfect for the "ChooseKeyword" form because it's supposed to simulate a dialog box but I need the Request form to look like a normal browser session.

Thanks,

-Snocross

PS:  Why don't you have EE combine your STAMP points with your ZVONKO points?  Seems you have worked to hard to lose all those points.
Sno do not ask; I have tried and tried, but got no expert points transfered to my new account.

But for your new window problem I have two improvements.
First is an improved setFields() function:
function setFields() {
 var req = window.location.href+'&';
 var f1 = document.forms[0].ListChosen;
 if (req.match(/&keyword=(.+)\&/i)) {
   f1.value = unescape(RegExp.$1).split('&')[0];
 };
};

second improvement is in this "ChooseKeyword" form; either give window.open parameter to get LocationBar opened (does not work :-), or open the "Request" form in the parent window where "Document" was open. Here the javascript for this two options in addToList() function:
window.open('/bachwebworks/protips.nsf/RequestOpenForm&keyword='+escape(val)+'&par2=xx','Request','locationbar=yes');
window.opener.location.href='/bachwebworks/protips.nsf/Request?OpenForm&keyword='+escape(val)+'&par2=xx';

and here more options beside parameter 'locationbar=yes':
dependent=no
 height=200
 hotkeys=yes
 innerHeight=200
 innerWidth=200
 locationbar=no
 menubar=no
 resizable=yes
 screenX=100
 screenY=30
 status=yes
 width=200

Good luck,
zvonko
Ok, I will hopefully try this tonight!
Thanks so much for your help!  It worked awesome.
Thank you Sno for the A and for the feedback <|;-)
You're welcome, I appreciate your expertise... now, keep your eyes open for another question regarding this...