This is my first post so I hope someone can help me out. I am very new to javascript and am having a problem calling a function using the onClick event linked to a button. I have produced the code below which generates a form with a series of boxes to complete. The user inputs a number at the first window.prompt which generates a form with the corresponding number of rows of fields. When the form has been completed I want to be able to call a function called assess_risk which currently only has a window.alert in it for testing purposes but will ultimately collect the data from each form field in a series of arrays which have been defined, and then used to perform some calculations. However when I click the button which calls the assess_risk function I get an error in IE. In Firefox 1.5 it also doesn't work and using the javascript console it says the error is assess_risk not defined.
I would really appreciate any help in understanding where I'm going wrong!
thanks for your quick reply but I had already tried it with and without the quotes around the function call and it makes no difference, still get same errors?
ok i think i found the real problem this time
(although im pretty sure ur going to need those qutoes anyways)
the problem is that you are putting your "document.write()" commands inside a function in the <head> tags. because of this, the javascript compiler does not know where to put the text. on thing u could do, is create a <div> element and put the text inside that, with the .innerHTML property.
ok i dont know if i explaed that well, so im going to add my own version of the code SOON
ok i got it working this time
i have the code attached
another adavantage of using the inner HTML property instead of the documwnt.write90 method is that the link stays on the page, so u can rerun the program multiple times.