Solved

Simple java question

Posted on 2001-07-25
17
164 Views
Last Modified: 2013-12-18
Hi experts,

I'm trying to use some Javascript to get some things done in my web enabled application.

I want to extract the value of a field in a document (DocUniqueID) and paste this value in a function that will open a new window.

for extracting the data from the field I'm using this code in the JS Header:

function extractDocId () {
    id=window.document.forms[0].DocUnqiueIDTxt.value
    alert(id)
}

The alert is there to check it's value for debugging.

In a click event I'm calling the extractDocId function and the document is present in a frameset of three frames.

When I check this on the web, errors occur even when I remove the alert(id). I think it has something todo with the frames, because when I use the same code in a test database, whitout use of frames, this code is running.

AND...

Let's say the previous code is running, how do I get the variable "id" in the URL I want to open. Is is something like this ?

newWindow=open.window("http://domino1.test.nl/db.nsf/" + id + "/$FILE/attach.doc?OpenElement")

You see, I want to open a attachment from a specific document in a new window...

Greetings,

Bob
0
Comment
Question by:oosterbaan
  • 6
  • 5
  • 5
  • +1
17 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6320202
You are coorect frames and document have their own place in JS DOM

To refer a field value in a frame use this

parent.frames[0].form.field1.value

Where 0 is the index of the frame from top left to bottom right, instead of 0 u can give the frame name, this will extract the value appropriately and use that doc id value in the url that u mentioned last


~Hemanth
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6320906
You can leave out the window classification in your command and the problem will no longer exist.

To get the value, you need to have your function return the extracted value.

Here's the complete JavaScript :
In the JS Header:
function extractDocId()
   {
   return document.forms[0].DocUniqueIDTxt.value;
   }

In your onclick event to open the new url :
newWindow=open.window("http://domino1.test.nl/db.nsf/" + extractDocID() + "/$FILE/attach.doc?OpenElement")

Also keep in mind that the field has to be on your form as a field for you to be able to reference the value. If it's a computed field for example, you also need to check the "Generate HTML for all fields" option on the second tab of the form properties.
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6323963
ha ha ha...

very well boys and girls; but absolutely unnecessary <|;-)

Instead of doing this complicated transfers in JavaScript simply allow Domino to generate the JavaScript code as passtru text.
Either make it ComptedText or embed a field to produce this DocId. Or even better: do not fetch the attachment by docid but by a view with first column sorted with @AttachmentNames.

Do you need a more detailed instruction or are this ideas enough for you Bob?
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6324737
It's not possible for me to create a view that is sorted with @AttachmentNames, because all the attachments have the same name...

Whatever I do to extract the value of the Field I get a error message whitin the browser, that saying that document.form.DocumentUniqueIDTxt is not a object. I have tried different variants, removed the form out of the frame, set the option "generate HTML for all fields"..nothing worked

I have tried:

document.form[0].DocumentUniqueIDTxt.value
document.form.DocumentUniqueIDTxt.value
window.document.DocumentUniqueIDTxt.value


0
 
LVL 10

Expert Comment

by:zvonko
ID: 6325069
the format document.form[0].DocumentUniqueIDTxt.value is valid only if you can see this value in html source code like this:
<input type=hidden name=DocumentUniqueIDTxt value=FFFFF >

(if you see only the value on the page but not in html input vars than it is a plain text and not a variable accessible by JavaScript).

0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6325681
You forgot my last remark, Bob. Check the checkmark next to "Generate HTML for all fields" on the second tab of the form properties dialog box. This will always create the input field in the browser. When the document is opened for reading it will be hidden, but still accessible for JavaScript.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6325794
Hi guys,

I did set the option jerrith (read my previous comment) and I have checked in the source if the line was present (like zvonko said) and it was exactly there...

I have used this code:

document.form[0].DocumentUniqueIDTxt.value

but the result in the debugger is saying:

Error: document.form.0'is not a object

Phhhhhh...Java isn't as simple as they said

Greetings,

Bob
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6325816
You need to put document.forms[0].DocumentUniqueIDTxt.value

The extra s is important. document.form does not exist, document.forms does.
If you made this typo only in posting the comment, but not in your actual code, where is your code located ? In a hotspot/button on the form ?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Expert Comment

by:zvonko
ID: 6325966
good JM. ;-)

I was also cut'n&pasting upper code and oversee missing document's S :-)

...but still my opinion is that this all is wrong strategy. As soon as Bob state where he want to call this window.open(URL) and why he want to call window.open(URL) the explanation how to produce this window.open(URL) will be easy for me.

Until now Bob state he want to open attach.doc This looks like WinWord document. They are never oppened inplace, always as new window. So this JavaScript window.open(URL) is unnecessary, 'cose simply URL would be enough...

Let's look for more details...

So Bob please explain more in datail wath do you need this code for and wath do you like to gain with it.

0
 
LVL 8

Accepted Solution

by:
Jean Marie Geeraerts earned 50 total points
ID: 6326222
Nope, in Internet Explorer 5 word documents can be opened inside the current window. Anyway, if it's to be a fixed link to the attachment from within the document I normally use a very simple HTML-link passthrough like
[<A HREF="URL">descriptive text</A>]
which I calculate using computed text.

Bob,
I may have a suggestion for a formula you can use in a comupted text to display a list of attachments as hyperlinks in read mode and as checkboxes in edit mode to be able to remove selected attachments. :

@if(!@Attachments; @Return(""); "");
@if(@IsDocBeingEdited;
"[<b>Select attachments to be removed:</b><br>] +
@Implode("[input type=\"checkbox\" name=\"%%Detach\" value=\"" + @AttachmentNames + "\">" + @AttachmentNames; "<br>]");
"[<b>Attached documents</b><br>]" +
@Implode("[<a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + @AttachmentNames + "\">" + @AttachmentNames + "</a>";"<br>]))

The above code will use the name of the attachments and add the necessary html-code using the @implode function to display the checkbox list in edit mode and the list of hyperlinks in read mode.
Looks complicated, but when you know HTML and you break down the code to it's seperate elements it's quite straight-forward.

Anyways, let us know if you get it working.
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6326230
P.S.: Sorry for the error before, I forgot the extra 's' when posting so, it's my fault it wasn't working.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6326311
Thanks guys for all your comments, but it's working fine now. The S was the "problem" (-:
BTW...I don't want to open a .doc file, but a .pdf file only on the web. The function I'm trying to achief is when a document is opened (on the web), the attachment present in this document will open automaticly whitin a seperate window, so I thought to write a Javasript, that will run OnLoad...

If you have other suggestion, please let me know....

Greetings,

Bob
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6326313
You both deserve points, so I will open a dummy question for zvonko to give him his points...

Greetings,

Bob
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6327932
Thank you Bob for your offer, but do not make me ashaimed...

The only thing I did was sarcasm, real work was done by JM.

So please delete the other points. I do realy need points, but not this way, OK <|;-)

Greetings,
zvonko
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6328030
Hi zvonko,

Your a good human (-:

I hope to see you in my next questions with or whitout your sarcasm (-;

Greetings,

Bob
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6335988
wath does mean "good human"? I only take care about my wizzard image <|;-)  (hi hi :-))
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6379301
I just got back from my holliday. Thanks for the A, Bob!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
DAOS - Backup / Restore 2 171
Lotus notes email code 2 113
Add a cc field to email code 6 94
Bulk lotus notes account creation 3 68
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now