onclick event/checkboxes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DI
Forum Newbie
Posts: 1
Joined: Thu Oct 23, 2003 12:07 pm

onclick event/checkboxes

Post by DI »

My form has a number of checkboxes depending on the number of records in a databases,once the user checks any of these boxes i want to be able to populate an array with the value check and afterward add to a table.
Is there anyway of using the onClick event without using java script ie call a PHP function onclick?
Im relatively new to PHP and would appreciate any help
Thanks
DI
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

php runs server-side. It's not aware of what's going on client-side until the next http-request is made.
but maybe this litte script gives you a hint

Code: Select all

<html>
	<head>
		<title>checkbox test</title>
	</head>
	<body>
		<fieldset><legend>paramters POSTed with this request</legend>
			<pre><?php print_r(@$_POST); ?></pre>	
		</fieldset>
		<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
			<input type="checkbox" name="chk[]" value="1" />
			<input type="checkbox" name="chk[]" value="2" />
			<input type="checkbox" name="chk[]" value="4" />
			<input type="checkbox" name="chk[]" value="8" />
			<br />
			<input type="submit" />
		</form>
	</body>
</html>
Post Reply