Re: checkbox please ...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear oedin
Please Try This
<form name="frmCheckBoxTest">
	<table width="500px" border="1" cellpadding="0" cellspacing="0">
	<?php 
	/*
		YOUR CODE
		php:
		[start loop ..]
		
		<input type='checkbox' value='$row[0]'>
		
		[end loop ..]
		
		In your code there is no way to identify your checkbox
		we can identify an element by using ID or NAme
		The ID attribute uniquely identifies an element within a document.
No two elements can have the same ID value in a single document. The
attribute's value must begin with a letter in the range A-Z or a-z and
may be followed by letters (A-Za-z), digits (0-9), hyphens ("-"),
underscores ("_"), colons (":"), and periods ("."). The value is
case-sensitive.
	*/
	for($intX = 0; $intX <= 10; $intX++){
					# HTML element tabledata
					# Unique ID for the TD -> td_ + value of loop variable
		print(	'<tr>
					<td id="td_'.$intX.'">
						<input type="checkbox" onclick="highlight(this);"
name="chkTestObject" id="chkTestObject'.$intX.'" value="'.$intX.'">
'.$intX.' 
					</td>
				</tr>');
				/*	# HTML TAG 		ELEMENT TYPE javascript function(event fireing
checkbox object as argument) highlight will be called while clicking
the checkbox 
					# NAME of the Element -> chkTestObject
					# Unique ID of the Element chkTestObject+ value of loop variable
					# assigning value to the element */
	}
	?>
	</table>
</form>
<?php print('<script language="javascript">var loopCount =
'.$intX.';</script>'); 
/* Passing the Loop count for Client side validation */
?>
<a href="javascript:__fncShowValues()">Show Checked Values [using form
tag]</a><BR>
<a href="javascript:__fncShowValuesGEBID()">Show Checked Values [using
getElementById]</a><BR>
<script language="javascript">
	function __fncShowValues(){
		// LOOP 
		for (i=0; i<loopCount; i++){
		//OR USE document.frmCheckBoxTest.chkTestObject[i].length INSTED OF
loopCount
			if (document.frmCheckBoxTest.chkTestObject[i].checked==true)
				alert("Checkbox at index "+i+" is checked! [USING
document.formname.elementname]")
		}
	}
	function __fncShowValuesGEBID(){
		for (i=0; i<loopCount; i++){
			if (document.getElementById('chkTestObject'+i).checked==true)
				alert("Checkbox at index "+i+" is checked! [USING
document.getElementById(elementID)]")
		}
	}
	function highlight(checkbox) {
		if (document.getElementById) {
			var tr = eval("document.getElementById(\"td_" + checkbox.value +
"\")");
		} else {
			return;
		}
		if (tr.style) {
			if (checkbox.checked) {
				tr.style.backgroundColor = "#FFFF00";
			} else {
				tr.style.backgroundColor = "#FFFFFF";
			}
		}
	}	
</script> 


Cheers
Ajaya Ghosh. S





PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-objects/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:php-objects-digest@xxxxxxxxxxxxxxx 
    mailto:php-objects-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux