Evan
Evan

Reputation: 1

Javascript function argument

I am using a javascript function and I am trying to pass a string of characters that come from form fields. I am trying to achieve this:

function_name(55,document,form.field1.value,form.field2.value)

but I am trying to pass the above as one argument, for example '44,55,66'

I tried the following without success:

'this.value+','.charAt(0)+document.class.Q_11_2c.value+','.charAt(0)+document.class.Q_12_3c.value'

Upvotes: 0

Views: 161

Answers (2)

bhu1st
bhu1st

Reputation: 1318

your function:

function_name(dataString) {
//parse the param string to get values you need 
//dataString.split("unique-delimiter")
} 

now call it as:

//make values a single string and pass it to the function
//mydataString = dataArr.join("unique-delimiter") ; 
function_name(mydataString);

Upvotes: 0

Basilevs
Basilevs

Reputation: 23896

If you want your function to accept a single argument, rewrite its definition accordingly and remove any charAt() from its argument in call.

Upvotes: 1

Related Questions