Forum Moderators: open

Message Too Old, No Replies

Open Multiple Documents With Checkboxes

How To Do In Javascript

         

jereece

10:06 pm on Apr 23, 2005 (gmt 0)

10+ Year Member



First of all let me say that I am posting this in the JavaScript section because my companies server does not support PHP or ASP, so I am assuming my only option is Javascript. I am not very expeienced with Javascript, but if someone can get me started with functional code, I know enough to read and add to it. Here's a description of what I am looking for.

I have about a hundred safety procedures. Examples include "Hand Protection Requirements", "Fall Protection Requirements", "Eye Protection Requirements", "Protection From Chemicals", etc.

What I would like to have is a web page with a list of questions such as,

[]Will you be working with tools?
[]Will you be climbing above 4 feet?
[]Will you be grinding, sanding or buffing?
[]Will you be working with chemicals?

Each question will have a check box in front of it to indicate Yes. Each question will be associated with a document. At the bottom of the page will be a button. Upon checking yes to the questions and clicking the button, a list of the associated procedures will be returned. Each document list will have a link to the document.

So basically what I want to develop is a safety self-assessment tool so workers can answer questions about what they will be doing and it would return a list of the appropriate procedures we have.

Again, if someone can get me started with a working example of how you would do this, I can modify and add to for my needs.

I really appreciate any help.

Jim

gph

10:50 pm on Apr 23, 2005 (gmt 0)

10+ Year Member



Are the documents describing the details of each selection very large? If not it would be easier to do this from a single page using display:none.

jereece

11:32 pm on Apr 23, 2005 (gmt 0)

10+ Year Member



Each individual safety procedure (document) is in PDF format (originally created in Word) and can be as short as 5 pages but some are as long as 30 pages. So the length varies depending on the subject. How to wear hearing protection is simple, but how to protect yourself when using various chemicals is much more detailed.

I did not think about it until now, but if what I really want can't be done, an option would be to OPEN each document that is checked. I just want to make it easy as possible for our workers to get the safety information they need to minimize injuries in our workplace.

Also, I am open to other options if anyone can think of any.

Again, any help is appreciated very much.

Jim

gph

1:05 pm on Apr 24, 2005 (gmt 0)

10+ Year Member



Yes I think linking each question to a pdf would be more user friendly.

Maybe you could group the questions into categories like "Working with chemicals", "Working with power tools", "Safe activities" etc.

rocknbil

4:12 pm on Apr 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why don't you just use the appropriate links?

[]Will you be working with tools? <a href="tools.pdf">Safe Tool Usage</a>
[]Will you be climbing above 4 feet? <a href="height.pdf">Working with height</a>
[]Will you be grinding, sanding or buffing? <a href="grinders.pdf">Grinders and Sanders</a>
[]Will you be working with chemicals? <a href="hazmat.pdf">Hazardous Materials Precautions</a>

Without sending something to the server side, not much you can do because Javascript will "lose" the values from one page to the next (you could set cookies, but that's more complex.) This will work (I think. :-) )

<input type="checkbox" name="tools" value="1"> Will you be working with tools?
.... etc.
<input type="button" onClick="openPages(this.form);" value="Open Documents">

function openPages(form) {
var flds = new Array('tools','height','grinders','hazmat');

for (i=0;i<flds.length;i++) {
var file = flds[i] . '.pdf';
var day = new Date(); // forces a newwindow to open for
var id = day.getTime(); // each win by creating unique ID for the name
var chk = eval('form.'+flds[i]);
if (chk.checked == true) {
var win = open(file,id,'width=500,height=500,scrollbars,resizable');
}
}

}