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 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



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:
script language=JavaScript
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; }
/script
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[] ???  Im 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 Ive looked online and cant seem to find anything, so
thought Id 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

2004-10-31 Thread Mulley, Nikhil
Actaully No , as Javascript has to run at Web Browser end and PHP has to run at Server 
Side , And more at matter javascript memory ( variable values ) cannot be shared with 
PHP memory ( variable values ) , If you want want to share the variable values or 
result values then you can do away with PHP-PEAR Extension JavaScript.



Nikhil.

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: Sunday, October 31, 2004 6:35 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] PHP  Javascript


On Saturday 30 October 2004 12:33, balwantsingh wrote:

 can anybody guide me how to embed php script into javascript. 

You can't.

 actually i am 
 using a function in  javascript and want that when this fuctions is called
 than some values to be stored in php session so that the values can be
 displayed in next page.

You can pass values from client-side using Javascript either via the URL 
($_GET) or form ($_POST) or cookies ($_COOKIE).  You can't manipulate the 
session variables directly.

-- 
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
--
/*
Defeat is worse than death because you have to live with defeat.
  -- Bill Musselman
*/

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


Re: [PHP-DB] PHP Javascript

2004-10-30 Thread Jason Wong
On Saturday 30 October 2004 12:33, balwantsingh wrote:

 can anybody guide me how to embed php script into javascript. 

You can't.

 actually i am 
 using a function in  javascript and want that when this fuctions is called
 than some values to be stored in php session so that the values can be
 displayed in next page.

You can pass values from client-side using Javascript either via the URL 
($_GET) or form ($_POST) or cookies ($_COOKIE).  You can't manipulate the 
session variables directly.

-- 
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
--
/*
Defeat is worse than death because you have to live with defeat.
  -- Bill Musselman
*/

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



Re: [PHP-DB] php, javascript and db - your help is needed

2004-07-19 Thread Nilo César Teixeira
Hi Cohen,

It´s really trivial. You show put a block that tests if a student is
selected, like

? if  (strlen($_REQUEST[student_id])0) { ?
DO SOME STUFF

SCRIPT
/* And add this simple feature to select the student passed as parameter */
/* Assuming that the select is inside a form named 'f' */
function selectOption(selectName, value) {
  var s =  document.f.elements[selectName];
  var found = false;
  for (var i=0; is.options.length  !found; i++) {
if (s.options[i].value==value) {
  s.selectedIndex=i;
  found = true;
}
  }
}

selectOption('student_id',?=$_REQUEST[student_id]?);
/SCRIPT
? } ?
- Original Message - 
From: G. Cohen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, July 18, 2004 1:30 PM
Subject: [PHP-DB] php, javascript and db - your help is needed


 Hello,

 I have a HTML form with 2 select boxes, lets say students and courses.
When
 the from loads for the first time, I fill the students select box with
data
 from database. The courses selectbox remains empty.
 When the user selects a value from the students selectbox (onchange
event),
 I should go to the db to reterive the courses for the selected student and
 fill the courses selectbaox. I found it very complicated to do the
 interaction between javascript and php: apparently, I have to submit the
 from for the selected student id to be passed as a parameter to php (so
that
 php can access the db with the student id and retrieve his courses), and
at
 the same time I want the form to stay with the list of students, and the
 selected student. This should not be that hard, should it?! this is
 something trivial, I hope?
 I also tried using cookies, with no success.
 If someone knows how to do that, please let me know.

 Best Regards,
 G. Cohen

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



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



Re: [PHP-DB] php, javascript and db - your help is needed

2004-07-18 Thread Marcjon
You could use a if/while construct. Something like:

select name=\courses\
?php
if ($_POST['studentselect']){
$result = mysql_query(SELECT courses FROM students WHERE student_name =
' . $_POST['studentselect'] . ');

while ($row = mysql_fetch_assoc($result))
{
echo option value=.$row['course']..$row['course']./option;
}
}
?
/select

Basically you would submit the form, and if a student was selected, it
would populate the list with their courses from the database.

-- 
  Marcjon

- Original message -
From: G. Cohen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Date: Sun, 18 Jul 2004 19:30:49 +0300
Subject: [PHP-DB] php, javascript and db - your help is needed

Hello,

I have a HTML form with 2 select boxes, lets say students and courses.
When
the from loads for the first time, I fill the students select box with
data
from database. The courses selectbox remains empty.
When the user selects a value from the students selectbox (onchange
event),
I should go to the db to reterive the courses for the selected student
and
fill the courses selectbaox. I found it very complicated to do the
interaction between javascript and php: apparently, I have to submit the
from for the selected student id to be passed as a parameter to php (so
that
php can access the db with the student id and retrieve his courses), and
at
the same time I want the form to stay with the list of students, and the
selected student. This should not be that hard, should it?! this is
something trivial, I hope?
I also tried using cookies, with no success.
If someone knows how to do that, please let me know.

Best Regards,
G. Cohen

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

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



Re: [PHP-DB] php, javascript and db - your help is needed

2004-07-18 Thread Justin Patrin
On Sun, 18 Jul 2004 13:24:01 -0700, Marcjon [EMAIL PROTECTED] wrote:
 You could use a if/while construct. Something like:
 
 select name=\courses\
 ?php
 if ($_POST['studentselect']){
 $result = mysql_query(SELECT courses FROM students WHERE student_name =
 ' . $_POST['studentselect'] . ');
 
 while ($row = mysql_fetch_assoc($result))
 {
 echo option value=.$row['course']..$row['course']./option;
 }
 }
 ?
 /select
 
 Basically you would submit the form, and if a student was selected, it
 would populate the list with their courses from the database.
 
 --
   Marcjon
 
 
 
 - Original message -
 From: G. Cohen [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Date: Sun, 18 Jul 2004 19:30:49 +0300
 Subject: [PHP-DB] php, javascript and db - your help is needed
 
 Hello,
 
 I have a HTML form with 2 select boxes, lets say students and courses.
 When
 the from loads for the first time, I fill the students select box with
 data
 from database. The courses selectbox remains empty.
 When the user selects a value from the students selectbox (onchange
 event),
 I should go to the db to reterive the courses for the selected student
 and
 fill the courses selectbaox. I found it very complicated to do the
 interaction between javascript and php: apparently, I have to submit the
 from for the selected student id to be passed as a parameter to php (so
 that
 php can access the db with the student id and retrieve his courses), and
 at
 the same time I want the form to stay with the list of students, and the
 selected student. This should not be that hard, should it?! this is
 something trivial, I hope?
 I also tried using cookies, with no success.
 If someone knows how to do that, please let me know.
 
 Best Regards,
 G. Cohen
 

PHP is a server-side language, so any further processing can only be
done when the browser sends a new request. You have to refresh *some*
page to get new data.

It is possible to use a hidden iframe to send a request, then parse it
with JS and display it in the main page, but this isn't trivial.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



RE: [PHP-DB] PHP-Javascript

2001-05-23 Thread Beau Lebens

you are trying to use a php header to redirect... there is no need, just do
it via javscript, and keep your variables where they belong :)

script language=javascript
var id;
uid = prompt(Enter your ID,Your ID);

document.location.href = 'ndex.php?uid=' + uid;
/script

easy :)

// -Original Message-
// From: vipin chandran [mailto:[EMAIL PROTECTED]]
// Sent: Wednesday, 23 May 2001 2:11 PM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] PHP-Javascript
// 
// 
// Hi,
// Is there any method by which I can attach a javascript variable to a 
// query string.See the following..
// script language=javascript
// var id;
// uid = prompt(Enter your ID,Your ID);
// /script
// ?
//  print header(Location: index.php?id=.this is where I should have
// the js variable uid);
// ?
// Please solve this.
// Thanx. 
// 
// vipin chandran
// [EMAIL PROTECTED]
// 
// 
// -- 
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, e-mail: [EMAIL PROTECTED]
// For additional commands, e-mail: [EMAIL PROTECTED]
// To contact the list administrators, e-mail: 
// [EMAIL PROTECTED]
// 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]