Page 1 of 1

running javascript on php page or 2 submit buttons in 1 form

Posted: Sun Jun 08, 2003 10:04 am
by deejay
HI

i have a function in javascript

Code: Select all

function tickAll() {
		document.form1.q1.checked = true;
		document.form1.q2.checked = true;
		document.form1.q3.checked = true;
		
}
and called up with

Code: Select all

<INPUT type="button" name="submit" onClick="javascript:tickAll()" value="Accept All" >
but cant seem to get this to work on a PHP page. According to post i have read there shouldn't really be a problem. I have also tried to make a tick all in php instead but donot undersatnd how to use 2 submits in 1 form.

Any help is appreciated, thanks.

Posted: Sun Jun 08, 2003 2:48 pm
by volka
this one works fine for me

Code: Select all

<html>
	<head>
		<script type="text/javascript">
			function tickAll() {
      	document.form1.q1.checked = true;
      	document.form1.q2.checked = true;
      	document.form1.q3.checked = true;
      	return true;
    	}
    </script>
	</head>
	<body>
		<pre><?php print_r($_POST); ?></pre>
		<hr />
		<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
			<input type="checkbox" name="q1" id="q1"/><label for="q1">q1</label><br />
			<input type="checkbox" name="q2" id="q2"/><label for="q2">q2</label><br />
			<input type="checkbox" name="q3" id="q3"/><label for="q3">q3</label><br />
			<INPUT type="button" name="submit" onClick="javascript:tickAll()" value="check All" />
			<INPUT type="submit" name="submitAll" onClick="javascript:tickAll()" value="submit all" />
			<input type="submit" />
		</form>
	</body>
</html>

Posted: Mon Jun 09, 2003 2:53 am
by deejay
thanks for the reply, i will not have a chance to look at this now until the end of today. Will let you know whether I can get this to work for me then.