RE: [PHP-DB] PHP / Javascript question

2004-11-16 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 16 November 2004 03:03, Chris Payne wrote:

This is OT, really, but because it's an easy answer:

> if ( document.removeitems.del.value == "" )

> BUT because the tickboxes information is stored in a PHP
> Array called del[]
> I am having major problems getting it to work.

You shouldn't be, since any good JavaScript text will tell you that, by
definition, x.y is identical to x['y']; so:

document.removeitems['del[]']

will get you started.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] PHP / Javascript question

2004-11-15 Thread Gabino Travassos
Hi there everyone,
I have a form with check boxes and with PHP I use the array feature for the
form name.  Now I need to check if the tickboxes are ticked and if not
return an error, normally with javascript I would use:

function validate_form ( )
{  valid = true;
if ( document.removeitems.del.value == "" ){
   alert ( "You cannot remove an item if it is not selected." );
   valid = false;  }
   return valid; }

BUT because the tickboxes information is stored in a PHP Array called del[]
I am having major problems getting it to work.  Does anyone know how to
determine with javascript if any boxes are ticked, when the name for the box
is an Array such as del[] ???  I’m grabbing the data from my MySQL DB
without a hitch etc …. And I know technically this is more MySQL / PHP list,
but it is related and I’ve looked online and can’t seem to find anything, so
thought I’d try here as usually you are all very helpful.
Thank you
Chris
+
Hey Chris
So, PHP creates HTML and Javascript on the server end. Javascript is read in 
the browser. By the time the Javascript gets to do checks to see whether a 
box is pressed or not, the PHP array is long-gone.

You should run your PHP, and then check the source code it makes in the 
browser. What you'll hopefully see is a bunch of form boxes with the names 
they got from the array. So, use Javascript to check those names.

If your list is dynamic, so there might be del1, del2, del3, etc., you'll 
want to use a loop in Javascript to run through the names. To find out how 
many there are for the loop, PHP can dump a javascript variable called 
loopAmount or something.

Luck.
Gabino 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] PHP / Javascript question

2004-11-15 Thread Jason Wong
On Tuesday 16 November 2004 11:03, Chris Payne wrote:

> BUT because the tickboxes information is stored in a PHP Array called del[]
> I am having major problems getting it to work.  Does anyone know how to
> determine with javascript if any boxes are ticked, when the name for the
> box is an Array such as del[] ???

manual > PHP and HTML

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Stone's Law:
 One man's "simple" is another man's "huh?"
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php