View Full Version : Trouble passing a parameter to a function?

01-25-2006, 04:04 AM
In the bit of code below, when I try to pass the variable 'field' to the function 'checkIt', in what form must I pass it? I tried "field" and + field + as shown below, but in each case I get javascript errors. If I hardcode field with double quotes around it, I am ok. I know field itself is also ok, because alert(field) shows the expected value.

function processIt(field) {
checkIt(+ field +).innerHTML = newText;


01-25-2006, 05:09 AM
Since field is a variable you passed into the processIt function you should be able to just pass it on without any delimiters, checkIt(field).


01-25-2006, 10:48 AM
What checkIt() is? a function? This case it woun't work... What in fact are you trying to do? Can you detail and show us the rest of your code?

01-25-2006, 08:40 PM
Thanks for the response... Well, what I am trying to do is perhaps more simply shown here... I want to pass on the value 0 (ie form=0)to a routine so that searchfrm0 will be operated on, but I get the error message that formnm is undefined...

var timerID = null;
var timerOn = false;
var timecount = 1000;
function startTime(form) {

if (timerOn == false) {
var formnm= 'searchfrm'+form;
timerID=setTimeout( "hideAll(formnm)" , timecount);
timerOn = true;
function hideAll(form) {
getObject(form).style.visibility = "hidden";
timerOn = false;

01-25-2006, 08:44 PM
And I just figured out that what I need is to define formnm as var formnm before the function declaration... Thanks again!