read variable into string

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

read variable into string

Post by gurjit »

i pass through a variable called theval which holds a value such as 'M32'
when i try to make the checkbox value true it says error

'form1.theval.[0]' is null or not an object.

it does not convert theval into M32 and pass through form1.M32[0].checked = true.

this is my code

function clicksub(theval) {
form1.theval[0].checked = true
}


i just want to check the first checkbox.

how can i convert the 'theval' parameter passed through here.

In the form all i do is

<input onclick="clicksub('<?php echo "m$loc_id$school_id";?>')" id="<?php echo "m$loc_id$school_id";?>" type="Checkbox" name="stuid[]" value="<?php echo $stuid; ?>"> <?php echo $stu_fname1; ?> <?php echo $stu_fname2; ?> <?php echo $stu_lname; ?> <?php echo "<br>"; ?>
sbe
Forum Newbie
Posts: 2
Joined: Thu Jul 10, 2003 11:58 am

Post by sbe »

Try form[theval+'[0]'].checked.
Post Reply