[PHP] javascript cookie dissapears when adding session_start()

2013-03-20 Thread Norah Jones
I've been working on a PHP/Javascript Cookie Notify (Including multiple 
language support). Now I have one small problem, when session_start() is not at 
the top, the cookie message works as it should be. 
Now I am trying to add session_start(); at the top, as this will load the 
current language file the visitor has set it to. But then the cookie message 
will not show.
I've cleaned all my cookies, and still can't get it to work ...
I've put up a small code on jsFiddle, but when session_start(); is at the top, 
it launches correctly in jsFiddle. which can be viewed (here).
Does anyone know what i'm doing wrong? And would you be able to explain me what 
I am doing wrong?

Thanks



Re: [PHP] javascript cookie dissapears when adding session_start()

2013-03-20 Thread ma...@behnke.biz
Please re-send the link for your code.

 Norah Jones nh.jone...@gmail.com hat am 20. März 2013 um 15:19 geschrieben:


 I've been working on a PHP/Javascript Cookie Notify (Including multiple
 language support). Now I have one small problem, when session_start() is not
 at the top, the cookie message works as it should be.
 Now I am trying to add session_start(); at the top, as this will load the
 current language file the visitor has set it to. But then the cookie message
 will not show.
 I've cleaned all my cookies, and still can't get it to work ...
 I've put up a small code on jsFiddle, but when session_start(); is at the top,
 it launches correctly in jsFiddle. which can be viewed (here).
 Does anyone know what i'm doing wrong? And would you be able to explain me
 what I am doing wrong?

 Thanks


--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

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



Re: [PHP] Javascript detection

2011-04-28 Thread Geoff Lane
 On Thursday, April 28, 2011, tedd wrote:
 
 To answer your question in a new thread.

 No, the $_SERVER super-global isn't going to give you anything nor is 
 anything else like it.

 You see, PHP has a difficult time detecting IF Javascript is turned 
 ON in the client's browser because PHP is history by the time the 
 browser does anything, including running Javascript.

Thanks, Tedd. That's how I suspected things to be. However, the list
was very quiet, I might have missed something, and so I felt it
couldn't hurt to ask. TBH I'd already done:

 echo pre;
 print_r ($_SERVER);
 echo /pre;

and didn't spot anything there that I thought would give me the info I
sought - but then I don't know the purpose of every element of that
array and $_SERVER is not the only superglobal!

 As Yogi Berra once said; It's always hard to predict things 
 especially when it deals with the future.

However, once the browser has requested a transfer via HTTP that
request is in the past and that request is where stuff that lets you
know some of the browser's capabilities (e.g. HTTP_ACCEPT) comes from.
So it would be possible by a similar mechanism for a browser to tell
your script whether or not Javascript (or any other language for that)
is available.

 However, there are two ways to kind-of doing it:

 Way 1 --  I place an element in html that is hidden from the user's 
 view via css (display:none) and if Javascript is ON then Javascript 
 changes the css so that the element is shown to the user 
 (display:block). Here's an example:

This is the reverse of part of what I've done for the page in
question. I had a tabbed interface similar to:

div id=sect01 style=display:block;
[stuff]
/div
div id=sect02 style=display:none;visibility:hidden;
[stuff]
/div
...

However, the second div must be visible if JS isn't available
otherwise the user can't access that section. So I've changed the
style of the second and subsequent divs to display:block and then used
an onLoad routine to change the .style.display and .style.visibility
attributes of the second and subsequent divs to none and hidden
respectively so that those who have JS get the full DHTML.

Now I also using AJAX on that page. However, I can use the fact that
the trigger events aren't handled if JS isn't available to just
retrieve what's actually needed at the time via AJAX if JS is
available or submit the full form if it's not. Of course, that
complicates things in the PHP on the server as the script then has to
handle both interim and final form submission.

FWIW, it's possible to detect whether or not Javascript is available,
but not AFAICT at 'first contact' because you need the 'first contact'
page to do something to prove that JS is available, from which you can
assume that JS is not should that something not be done. For example,
you can make the link to a page into a form submission - e.g:

  form name='jstest' action='myscript.php' method='post'
  input type='hidden' name='wehavejs' value=1
  /form
  a href='myscript.php' 
onClick=document.forms['jstest'].submit();return(false);
  Click Here/a

The form is submitted if the browser has JS and so the hidden input
field is posted. However, if the browser doesn't have JS the default
behaviour occurs when the link is clicked and so the field is not
posted. Hence we can use isset($_POST['wehavejs']) to determine
whether or not the browser has JS capability.

Thanks again,

-- 
Geoff


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



Re: [PHP] Javascript detection

2011-04-28 Thread Per Jessen
tedd wrote:

 As Yogi Berra once said; It's always hard to predict things
 especially when it deals with the future.
 

He was quoting Niels Bohr:

http://www.quotationspage.com/quote/26159.html



-- 
Per Jessen, Zürich (10.2°C)


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



Re: [PHP] Javascript detection

2011-04-28 Thread tedd

At 9:02 AM +0100 4/28/11, Geoff Lane wrote:


FWIW, it's possible to detect whether or not Javascript is available,
but not AFAICT at 'first contact' because you need the 'first contact'
page to do something to prove that JS is available, from which you can
assume that JS is not should that something not be done. For example,
you can make the link to a page into a form submission - e.g:

  form name='jstest' action='myscript.php' method='post'
  input type='hidden' name='wehavejs' value=1
  /form
  a href='myscript.php' 
onClick=document.forms['jstest'].submit();return(false);

  Click Here/a

The form is submitted if the browser has JS and so the hidden input
field is posted. However, if the browser doesn't have JS the default
behaviour occurs when the link is clicked and so the field is not
posted. Hence we can use isset($_POST['wehavejs']) to determine
whether or not the browser has JS capability.

Thanks again,

--
Geoff


Geoff:

You are correct about first contact -- you need to launch the 
browser to check to see if the browser has javascript enabled. 
There's currently no way for the server to see what the user has 
selected for their browser before the browser launches.


It is true that the $_SERVER global provides all sorts of information 
about the requester and I suppose it could also contain the browser's 
javascript configuration, but it doesn't.


However, JavaScript detection doesn't require a user's response, as 
you have proposed via a form.


Instead, you can simply add an onload() operation to the page and 
detect javascript, such as:


http://www.webbytedd.com/b1/ajax-js-dection/

Or do it unobtrusively as I have shown before.

Cheers,

tedd


--
---
http://sperling.com/

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



Re: [PHP] Javascript detection

2011-04-28 Thread Ashley Sheridan
On Thu, 2011-04-28 at 10:17 -0400, tedd wrote:

 At 9:02 AM +0100 4/28/11, Geoff Lane wrote:
 
 FWIW, it's possible to detect whether or not Javascript is available,
 but not AFAICT at 'first contact' because you need the 'first contact'
 page to do something to prove that JS is available, from which you can
 assume that JS is not should that something not be done. For example,
 you can make the link to a page into a form submission - e.g:
 
form name='jstest' action='myscript.php' method='post'
input type='hidden' name='wehavejs' value=1
/form
a href='myscript.php' 
 onClick=document.forms['jstest'].submit();return(false);
Click Here/a
 
 The form is submitted if the browser has JS and so the hidden input
 field is posted. However, if the browser doesn't have JS the default
 behaviour occurs when the link is clicked and so the field is not
 posted. Hence we can use isset($_POST['wehavejs']) to determine
 whether or not the browser has JS capability.
 
 Thanks again,
 
 --
 Geoff
 
 Geoff:
 
 You are correct about first contact -- you need to launch the 
 browser to check to see if the browser has javascript enabled. 
 There's currently no way for the server to see what the user has 
 selected for their browser before the browser launches.
 
 It is true that the $_SERVER global provides all sorts of information 
 about the requester and I suppose it could also contain the browser's 
 javascript configuration, but it doesn't.
 
 However, JavaScript detection doesn't require a user's response, as 
 you have proposed via a form.
 
 Instead, you can simply add an onload() operation to the page and 
 detect javascript, such as:
 
 http://www.webbytedd.com/b1/ajax-js-dection/
 
 Or do it unobtrusively as I have shown before.
 
 Cheers,
 
 tedd
 
 
 -- 
 ---
 http://sperling.com/
 


I'm not sure if my earlier reply got through, but here it is again (or
at least the general gist of it)

There are ways you can detect if a browser is *capable* of running
Javascript using $_SERVER['HTTP_USER_AGENT'] and an up-to-date
browscap.ini file. This will allow you to check if the browser indicated
by the user agent. However, there are caveats to this approach:


  * A browser might be sending the wrong user agent string, there
are plenty of plugins which do this
  * A browser might be capable of running Javascript but might have
it turned off or otherwise blocked
  * Filtering may be going on by a proxy server or firewall that
strips out Javascript (sounds stupid but happens in paranoid
businesses)


Like everyone has mentioned thus far, it's better to use progressive
enhancement or try to avoid relying on Javascript at all. Even a website
as complex as Facebook allows users to go on it without needing a
browser that runs Javascript. Something as complex as Google Docs has a
very clear need for Javascript though, so you wouldn't expect that to
work without it.

Lastly, if you're creating the website for a government or business, you
really need to make it work without Javascript, as a lot of countries
make it illegal to discriminate against a disability, which you would be
doing if you made a site that was unusable without Javascript. After
all, there are many speech and Braille browsers out there that can't
take advantage of Javascript, and a lot of Javascript apps which require
mouse interaction to run (mouseover/hover events, etc)

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Javascript detection

2011-04-28 Thread Geoff Lane
On Thursday, April 28, 2011, Ashley Sheridan wrote:

 I'm not sure if my earlier reply got through, but here it is again (or
 at least the general gist of it)

Many thanks. I got your info the first time around but didn't respond
directly to you as Tedd made similar comments and I'd responded to his
post.

 Like everyone has mentioned thus far, it's better to use progressive
 enhancement or try to avoid relying on Javascript at all. Even a website
 as complex as Facebook allows users to go on it without needing a
 browser that runs Javascript. Something as complex as Google Docs has a
 very clear need for Javascript though, so you wouldn't expect that to
 work without it.

In my case, one of the controls I'm considering is a tiled map with up
to 16 tiles. This is on a page with four tabbed sections that takes
several seconds to load at broadband speeds. Also, the nature of the
site means that people may need to access it and use this form while
connected via mobile broadband or even GSM; connection media that are
usually both slow and paid for per unit of data transfer. I need to
record in hidden input fields the location of where a user clicks on
the map and also echo that click back in the form of a marker overlaid
on the clicked tile. Using AJAX, I can update just the two fields plus
one image. Without Javascript, the extra bandwidth needed to
unnecessarily download the entire page multiple times will cost my
users both time and money. So while I must ensure the site works
without Javascript, I really need the optimisation that JS brings.

 Lastly, if you're creating the website for a government or business, you
 really need to make it work without Javascript, as a lot of countries
 make it illegal to discriminate against a disability, which you would be
 doing if you made a site that was unusable without Javascript. After
 all, there are many speech and Braille browsers out there that can't
 take advantage of Javascript, and a lot of Javascript apps which require
 mouse interaction to run (mouseover/hover events, etc)

AIUI, a lot of countries (mine included) make it unlawful to knowingly
discriminate against the disabled. However, The Disability
Discrimination Act requires only that reasonable steps be taken to
avoid discrimination ... and making stuff accessible to the disabled
at considerable inconvenience and/or expense to everyone else is not
considered reasonable. Now where I can, I'll produce stuff that is
enhanced by images, colour, JS etc. but will still be usable in Lynx.
However, some stuff (e.g. mapping) won't work without graphics and so
is inherently unavailable to the visually impaired. It makes no sense
whatever to try to make such content work in speech and Braille
browsers. Thus making a site that's unusable without Javascript
doesn't necessarily constitute unlawful discrimination!

-- 
Geoff


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



[PHP] Javascript detection

2011-04-27 Thread tedd

At 6:42 PM +0100 4/27/11, Geoff Lane wrote:

However, I do have one residual question. I suspect the short answer
to this is No, but since the list is quiet I'll ask anyway:

Q: Is it possible to check whether Javascript is available on the
client without using client-side Javascript to create a form and hence
pass a variable that will only be set if Javascript is available on
the client? Is there something in $_SERVER etc. that can provide this
info?


Geoff:

To answer your question in a new thread.

No, the $_SERVER super-global isn't going to give you anything nor is 
anything else like it.


You see, PHP has a difficult time detecting IF Javascript is turned 
ON in the client's browser because PHP is history by the time the 
browser does anything, including running Javascript.


As Yogi Berra once said; It's always hard to predict things 
especially when it deals with the future.


However, there are two ways to kind-of doing it:

Way 1 --  I place an element in html that is hidden from the user's 
view via css (display:none) and if Javascript is ON then Javascript 
changes the css so that the element is shown to the user 
(display:block). Here's an example:


http://php1.net/b/show-hide/

Try clicking MORE

That way Javascript routines are shown to the user only if the user's 
browser is capable of running Javascript. If Javascript is OFF then 
nothing happens.


Way 3 -- another way is to use unobtrusive Javascript -- here's an 
example I did for my students:


http://www.webbytedd.com/aa/add-onclick-button/index.php

If Javascript is OFF, then the Add Another Record button is not 
seen by the user -- because it's not in the html.


However, if JavaScript is turned on, then the Add Another Record 
button is shown and becomes available as another option via DOM 
scripting. That's called unobtrusive Javascript.


Try it!

Now that doesn't mean that JavaScript can't call PHP, because it can 
-- look here:


http://webbytedd.com/b/timed-php/

and here:

http://webbytedd.com/a/ajax-site/

Those are examples of JavaScript running PHP scripts.

So, the world of mixing JavaScript and PHP is quite vast, but you 
have to know what run's what and when.


HTH,

tedd


--
---
http://sperling.com/

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



Re: [PHP] JavaScript Injection ???

2011-04-25 Thread Nathan Rixham

Stuart Dallas wrote:
On Monday, 18 April 2011 at 20:50, tedd wrote: 

The form as-is produced a javascript alert() and now it doesn't.


This is not a browser change because it's happening before the browser sees the 
response (try it with curl).


It is the browser, chrome will prevent execution because the code was 
sent in the request, just check the javascript console and you'll see 
something like:


  Refused to execute a JavaScript script. Source code of script found 
within request.


Best,

Nathan


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



Re: [PHP] JavaScript Injection ???

2011-04-25 Thread Daniel Brown
On Mon, Apr 25, 2011 at 19:12, Nathan Rixham nrix...@gmail.com wrote:

 It is the browser, chrome will prevent execution because the code was sent
 in the request, just check the javascript console and you'll see something
 like:

  Refused to execute a JavaScript script. Source code of script found within
 request.

Easy way to get around that, depending on where it lied and how it
was stored and accessed, is to inject it into the session.  Chrome
would obviously have no notion of session data.  An added step, but
proof positive that ALL data needs to be sanitized, not just GPC and
database.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] JavaScript Injection ???

2011-04-25 Thread tedd

At 7:45 PM -0400 4/25/11, Daniel Brown wrote:

On Mon, Apr 25, 2011 at 19:12, Nathan Rixham nrix...@gmail.com wrote:


 It is the browser, chrome will prevent execution because the code was sent
 in the request, just check the javascript console and you'll see something
 like:

  Refused to execute a JavaScript script. Source code of script found within
 request.


Easy way to get around that, depending on where it lied and how it
was stored and accessed, is to inject it into the session.  Chrome
would obviously have no notion of session data.  An added step, but
proof positive that ALL data needs to be sanitized, not just GPC and
database.

--
/Daniel P. Brown


Most excellent point!

Cheers,

tedd
--
---
http://sperling.com/

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



[PHP] JavaScript Injection ???

2011-04-18 Thread tedd

Hi gang:

Quite some time ago I had a demo that showed Javascript injection. It 
was where a user could type in:


script alert(Evil Code);/script

and a JavaScript alert would be shown.

But now my demo no longer works. So, what happened? Was there a php 
update that prohibited that sort of behavior or did hosts start 
setting something to OFF, or what?


If you know, please explain.

Thanks,

tedd
--
---
http://sperling.com/

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



Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Joshua Kehn
On Monday, April 18, 2011 at 1:06 PM, tedd wrote:
Hi gang:
 
 Quite some time ago I had a demo that showed Javascript injection. It 
 was where a user could type in:
 
 script alert(Evil Code);/script
 
 and a JavaScript alert would be shown.
 
 But now my demo no longer works. So, what happened? Was there a php 
 update that prohibited that sort of behavior or did hosts start 
 setting something to OFF, or what?
 
 If you know, please explain.
 
 Thanks,
 
 tedd
 -- 
 ---
 http://sperling.com/
Not that I know of. Are you talking about on-page injection, like comments and 
such? Normally JS injection would be that (bad scripts inserted by the user on 
a comment form or review page) or where you are using eval() and they dump bad 
code into there.

Regards,

-Josh___
Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com




RE: [PHP] JavaScript Injection ???

2011-04-18 Thread admin
Javascript:alert(Hello World);
The browsers have had many updates since last I seen this work.

PHP Server side.
JavaScript Client/Browser Side.




Richard L. Buskirk

You can't grow your business with systems that are on life support...

-Original Message-
From: tedd [mailto:t...@sperling.com] 
Sent: Monday, April 18, 2011 1:06 PM
To: php-general@lists.php.net
Subject: [PHP] JavaScript Injection ???

Hi gang:

Quite some time ago I had a demo that showed Javascript injection. It 
was where a user could type in:

script alert(Evil Code);/script

and a JavaScript alert would be shown.

But now my demo no longer works. So, what happened? Was there a php 
update that prohibited that sort of behavior or did hosts start 
setting something to OFF, or what?

If you know, please explain.

Thanks,

tedd
-- 
---
http://sperling.com/

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


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



Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Shreyas Agasthya
Is someone up to Cross Site Scripting? ;)

--Shreyas

On Mon, Apr 18, 2011 at 10:39 PM, Joshua Kehn josh.k...@gmail.com wrote:

 On Monday, April 18, 2011 at 1:06 PM, tedd wrote:
 Hi gang:
 
  Quite some time ago I had a demo that showed Javascript injection. It
  was where a user could type in:
 
  script alert(Evil Code);/script
 
  and a JavaScript alert would be shown.
 
  But now my demo no longer works. So, what happened? Was there a php
  update that prohibited that sort of behavior or did hosts start
  setting something to OFF, or what?
 
  If you know, please explain.
 
  Thanks,
 
  tedd
  --
  ---
  http://sperling.com/
 Not that I know of. Are you talking about on-page injection, like comments
 and such? Normally JS injection would be that (bad scripts inserted by the
 user on a comment form or review page) or where you are using eval() and
 they dump bad code into there.

 Regards,

 -Josh___
 Joshua Kehn | josh.k...@gmail.com
 http://joshuakehn.com





-- 
Regards,
Shreyas Agasthya


Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Ashley Sheridan
On Mon, 2011-04-18 at 22:43 +0530, Shreyas Agasthya wrote:

 Is someone up to Cross Site Scripting? ;)
 
 --Shreyas
 
 On Mon, Apr 18, 2011 at 10:39 PM, Joshua Kehn josh.k...@gmail.com wrote:
 
  On Monday, April 18, 2011 at 1:06 PM, tedd wrote:
  Hi gang:
  
   Quite some time ago I had a demo that showed Javascript injection. It
   was where a user could type in:
  
   script alert(Evil Code);/script
  
   and a JavaScript alert would be shown.
  
   But now my demo no longer works. So, what happened? Was there a php
   update that prohibited that sort of behavior or did hosts start
   setting something to OFF, or what?
  
   If you know, please explain.
  
   Thanks,
  
   tedd
   --
   ---
   http://sperling.com/
  Not that I know of. Are you talking about on-page injection, like comments
  and such? Normally JS injection would be that (bad scripts inserted by the
  user on a comment form or review page) or where you are using eval() and
  they dump bad code into there.
 
  Regards,
 
  -Josh___
  Joshua Kehn | josh.k...@gmail.com
  http://joshuakehn.com
 
 
 
 
 


I believe the reason for it not working now is because most browsers
won't pop up an alert without being triggered by something, i.e. a mouse
event, page load, etc. You might be able to change the code to do
something else like output to the firebug console, use document.write,
or change the status bar text (although for that to work you'll need to
change browser settings in most modern browsers like Opera, Fx, Chrome,
etc)

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Jim Giner

ad...@buskirkgraphics.com wrote in message 
news:005501cbfdeb$457839c0$d068ad40$@com...
 Javascript:alert(Hello World);
 The browsers have had many updates since last I seen this work.


?? You're saying that alert doesn't work on your browse?  Gee - it works 
on mine. 



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



RE: [PHP] JavaScript Injection ???

2011-04-18 Thread admin
Yes Alert works fine on my browsers but the hack to change the alert on
someone else's website has been fixed from browser updates.


Richard L. Buskirk

You can't grow your business with systems that are on life support...


-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
Sent: Monday, April 18, 2011 2:03 PM
To: php-general@lists.php.net
Subject: Re: [PHP] JavaScript Injection ???


ad...@buskirkgraphics.com wrote in message 
news:005501cbfdeb$457839c0$d068ad40$@com...
 Javascript:alert(Hello World);
 The browsers have had many updates since last I seen this work.


?? You're saying that alert doesn't work on your browse?  Gee - it works 
on mine. 



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


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



RE: [PHP] JavaScript Injection ???

2011-04-18 Thread Ashley Sheridan
On Mon, 2011-04-18 at 14:11 -0400, ad...@buskirkgraphics.com wrote:

 Yes Alert works fine on my browsers but the hack to change the alert on
 someone else's website has been fixed from browser updates.
 
 
 Richard L. Buskirk
 
 You can't grow your business with systems that are on life support...
 
 
 -Original Message-
 From: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
 Sent: Monday, April 18, 2011 2:03 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] JavaScript Injection ???
 
 
 ad...@buskirkgraphics.com wrote in message 
 news:005501cbfdeb$457839c0$d068ad40$@com...
  Javascript:alert(Hello World);
  The browsers have had many updates since last I seen this work.
 
 
 ?? You're saying that alert doesn't work on your browse?  Gee - it works 
 on mine. 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


I think it might have something to do with the origin of the data, as
running a quick example file works fine in Fx, Opera, Konqueror and
SeaMonkey on my computer, and even seem to work OK when run from my
local server (same machine but served from Apache instead of through the
local file:// protocol)

One other thing it could be is some sort of security mod (in PHP or
Apache) that is altering the actual HTML and isn't outputting what you
expect.
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] JavaScript Injection ???

2011-04-18 Thread tedd

At 1:09 PM -0400 4/18/11, Joshua Kehn wrote:

On Monday, April 18, 2011 at 1:06 PM, tedd wrote:


Hi gang:

Quite some time ago I had a demo that showed Javascript injection. It
was where a user could type in:

script alert(Evil Code);/script

and a JavaScript alert would be shown.

But now my demo no longer works. So, what happened? Was there a php
update that prohibited that sort of behavior or did hosts start
setting something to OFF, or what?

If you know, please explain.

Thanks,

tedd
--
---
http://sperling.comhttp://sperling.com/

Not that I know of. Are you talking about on-page injection, like 
comments and such? Normally JS injection would be that (bad scripts 
inserted by the user on a comment form or review page) or where you 
are using eval() and they dump bad code into there.


Regards,

-Josh


No, I had a simple form where IF the user entered:

script alert(Evil Code);/script

-- into the form's text field (i.e., $_POST['text'] ) AND clicked 
Submit, the form would


echo( $_POST['text'] );

-- and that would produce a JavaScript Alert.

Here's the form:

http://php1.net/a/insecure-form/index.php

It was a simple working example of JavaScript Injection. But it no 
longer works and I want to find out why. The most popular reason thus 
far is Browsers have changed, but I'm not sure as to what did 
change.


Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Daniel Brown
On Mon, Apr 18, 2011 at 14:42, tedd t...@sperling.com wrote:

 No, I had a simple form where IF the user entered:

 script alert(Evil Code);/script

 -- into the form's text field (i.e., $_POST['text'] ) AND clicked Submit,
 the form would

 echo( $_POST['text'] );

 -- and that would produce a JavaScript Alert.

 Here's the form:

 http://php1.net/a/insecure-form/index.php

 It was a simple working example of JavaScript Injection. But it no longer
 works and I want to find out why. The most popular reason thus far is
 Browsers have changed, but I'm not sure as to what did change.

Look at the post-processing source --- note the slashes.  Apply
stripslashes() to the output on the PHP side and all should be right
again with the world.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Ashley Sheridan
On Mon, 2011-04-18 at 14:42 -0400, tedd wrote:

 At 1:09 PM -0400 4/18/11, Joshua Kehn wrote:
 On Monday, April 18, 2011 at 1:06 PM, tedd wrote:
 
 Hi gang:
 
 Quite some time ago I had a demo that showed Javascript injection. It
 was where a user could type in:
 
 script alert(Evil Code);/script
 
 and a JavaScript alert would be shown.
 
 But now my demo no longer works. So, what happened? Was there a php
 update that prohibited that sort of behavior or did hosts start
 setting something to OFF, or what?
 
 If you know, please explain.
 
 Thanks,
 
 tedd
 --
 ---
 http://sperling.comhttp://sperling.com/
 
 Not that I know of. Are you talking about on-page injection, like 
 comments and such? Normally JS injection would be that (bad scripts 
 inserted by the user on a comment form or review page) or where you 
 are using eval() and they dump bad code into there.
 
 Regards,
 
 -Josh
 
 No, I had a simple form where IF the user entered:
 
 script alert(Evil Code);/script
 
 -- into the form's text field (i.e., $_POST['text'] ) AND clicked 
 Submit, the form would
 
 echo( $_POST['text'] );
 
 -- and that would produce a JavaScript Alert.
 
 Here's the form:
 
 http://php1.net/a/insecure-form/index.php
 
 It was a simple working example of JavaScript Injection. But it no 
 longer works and I want to find out why. The most popular reason thus 
 far is Browsers have changed, but I'm not sure as to what did 
 change.
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com/
 


From the looks of it you're only outputting the htmlentities version of
it, so it's outputting those script tags as lt;scriptgt; so the
browser would think the whole thing is text.
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] JavaScript Injection ???

2011-04-18 Thread tedd

At 2:46 PM -0400 4/18/11, Daniel Brown wrote:

On Mon, Apr 18, 2011 at 14:42, tedd t...@sperling.com wrote:


 No, I had a simple form where IF the user entered:

 script alert(Evil Code);/script

 -- into the form's text field (i.e., $_POST['text'] ) AND clicked Submit,
 the form would

 echo( $_POST['text'] );

 -- and that would produce a JavaScript Alert.

 Here's the form:

 http://php1.net/a/insecure-form/index.php

 It was a simple working example of JavaScript Injection. But it no longer
 works and I want to find out why. The most popular reason thus far is
 Browsers have changed, but I'm not sure as to what did change.


Look at the post-processing source --- note the slashes.  Apply
stripslashes() to the output on the PHP side and all should be right
again with the world.

--
/Daniel P. Brown


Daniel et al:

Sorry -- I'm not making myself clear.

The form as-is produced a javascript alert() and now it doesn't.

It doesn't make any difference if I use stripslashes() or not, it 
still will NOT produce a javascript alert as it used to do.


Seriously, try this:

?php

$insecure = $_POST['insecure'];
//$insecure = stripslashes($insecure);
?

h1tedd's Secure v Insecure form demo/h1

p
Enter (cut/paste the red) br/span class=red  lt;script 
alert(Evil Code); lt;/script/spanbr/ in the field below

and see what happens. The red is javascript code.
/p

form method=post action=index.php
p
Field: input type=text size=60 name=insecure
/p
p
input type=submit value=Submit Post
/p
/form

?php

if ($insecure != null)
{
echo(pThis is what you entered:/p);
echo(Input: $insecure);
echo(br);
$insecure = htmlentities($insecure);
echo(Input after htmlentites: $insecure);
echo(br);
}
?

?php include('../includes/footer.php'); ?

You can un-comment the stripslashes() function and it will still not 
produce a javascript alert.


Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Stuart Dallas
On Monday, 18 April 2011 at 20:50, tedd wrote: 
 Daniel et al:
 
 Sorry -- I'm not making myself clear.
 
 The form as-is produced a javascript alert() and now it doesn't.
 
 It doesn't make any difference if I use stripslashes() or not, it 
 still will NOT produce a javascript alert as it used to do.
 
 Seriously, try this:
 
 ?php
 
 $insecure = $_POST['insecure'];
 //$insecure = stripslashes($insecure);
 ?
 
 h1tedd's Secure v Insecure form demo/h1
 
 p
 Enter (cut/paste the red) br/span class=red lt;script 
 alert(Evil Code); lt;/script/spanbr/ in the field below
 and see what happens. The red is javascript code.
 /p
 
 form method=post action=index.php
 p
 Field: input type=text size=60 name=insecure
 /p
 p
 input type=submit value=Submit Post
 /p
 /form
 
 ?php
 
 if ($insecure != null)
 {
 echo(pThis is what you entered:/p);
 echo(Input: $insecure);
 echo(br);
 $insecure = htmlentities($insecure);
 echo(Input after htmlentites: $insecure);
 echo(br);
 }
 ?
 
 ?php include('../includes/footer.php'); ?
 
 You can un-comment the stripslashes() function and it will still not 
 produce a javascript alert.
Looks like some form of variable tainting. There was a proposal and a patch a 
while back, but all it did was emit a warning. I've looked at the PHP5 
changelog to see if this was added but can't find any reference to it being 
merged in.

This is not a browser change because it's happening before the browser sees the 
response (try it with curl).

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


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



Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Daniel Brown
On Mon, Apr 18, 2011 at 15:50, tedd t...@sperling.com wrote:

 It doesn't make any difference if I use stripslashes() or not, it still will
 NOT produce a javascript alert as it used to do.

Interestingly enough, I copied your index.php file to index2.php
on the server and modified it to use stripslashes() and, as you said,
it didn't work for me, regardless of how many times I tried.

In Chrome.

Switched over to Firefox and - wouldn't you know? - it worked like
a charm, exactly as expected, when stripslashes() was employed.  Of
course, without the call, it wouldn't work in any browser, but this is
now confirmed to be a browser issue.  Are you using Safari on your
Mac?  If so, give it a shot with Firefox and/or Internet Exploder.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] JavaScript Injection ???

2011-04-18 Thread tedd

At 4:44 PM -0400 4/18/11, Daniel Brown wrote:

On Mon, Apr 18, 2011 at 15:50, tedd t...@sperling.com wrote:


 It doesn't make any difference if I use stripslashes() or not, it still will
 NOT produce a javascript alert as it used to do.


Interestingly enough, I copied your index.php file to index2.php
on the server and modified it to use stripslashes() and, as you said,
it didn't work for me, regardless of how many times I tried.

In Chrome.

Switched over to Firefox and - wouldn't you know? - it worked like
a charm, exactly as expected, when stripslashes() was employed.  Of
course, without the call, it wouldn't work in any browser, but this is
now confirmed to be a browser issue.  Are you using Safari on your
Mac?  If so, give it a shot with Firefox and/or Internet Exploder.

--
/Daniel P. Brown


Bingo!

That did it!

You see, I'm writing a report for my student showing them the 
security hazards of forms. I figured it would be nice if I could show 
them and example of JavaScript injection. Now, iF FF for windows does 
the same thing, then that will be great.


You know, this teaching thing is a lot of work -- I'm below minimum wage now.

Cheers,

tedd

--
---
http://sperling.com/

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



[PHP] PHP/Javascript Job in Madrid

2009-06-03 Thread barbara

Hi all,
I am Bárbara Vilela and I work at Tuenti in the Human Resources 
department in Madrid. Tuenti is a social application and our mission is 
to improve the communication and transmission of information between 
people who know each other. Already the #6 most-trafficked website in 
Spain, Tuenti is also one of the fastest-growing Alexa Top 500 sites and 
one of the largest invite-only websites worldwide.
I am writing you because we have job opportunities for PHP/JavaScript 
Engineers that could be interesting for you.

You can find more information about this position here:
http://tbe.taleo.net/NA11/ats/careers/requisition.jsp?org=TUENTITECHNOLOGIEScws=1rid=25 

If you think you fit for this job please send me an e-mail with your CV 
and I´ll get in contact with you soon.

Thank you very much,
Bárbara Vilela Fernandes


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



[PHP] Javascript question

2009-03-02 Thread Boyd, Todd M.
Before some of you newbies feel like being heroes and jump all over me:

I KNOW THIS IS A PHP-RELATED LIST. IF YOU DON'T LIKE MY QUESTION, DON'T
ANSWER IT.

Now that that's out of the way... I have a Javascript question (and
maybe a Browser/DOM question) for you folks. I'm not sure this is
anything they teach you in any online/in-seat/self-taught Javascript
course that I've ever seen before, so I figured I would bring it here.

My boss asked me if I knew of a tool that would change the !DOCTYPE of
a page on-the-fly to test validation in different schemes (i.e., XHTML
Strict, Transitional, Loose, etc.). After a bit of looking around, this
is the solution I came up with (as a bookmarklet):

javascript:document.write('!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;' +
document.getElementsByTagName('html')[0].innerHTML);

However, I'm not sure it will fire any validation events, since
technically the page has already been loaded (Javascript is just adding
more text). I fear the case will be the same if the current page's
source is sent to a new browser window.

I'm not asking for any coding suggestions, necessarily--just curious as
to whether or not anyone knew if this will invoke browser validation
events or not. Comments and questions are more than welcome, though. :)

Cheers!


// Todd

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



Re: [PHP] Javascript question

2009-03-02 Thread Robert Cummings
On Mon, 2009-03-02 at 16:11 -0600, Boyd, Todd M. wrote:
 Before some of you newbies feel like being heroes and jump all over me:
 
 I KNOW THIS IS A PHP-RELATED LIST. IF YOU DON'T LIKE MY QUESTION, DON'T
 ANSWER IT.
 
 Now that that's out of the way... I have a Javascript question (and
 maybe a Browser/DOM question) for you folks. I'm not sure this is
 anything they teach you in any online/in-seat/self-taught Javascript
 course that I've ever seen before, so I figured I would bring it here.
 
 My boss asked me if I knew of a tool that would change the !DOCTYPE of
 a page on-the-fly to test validation in different schemes (i.e., XHTML
 Strict, Transitional, Loose, etc.). After a bit of looking around, this
 is the solution I came up with (as a bookmarklet):
 
 javascript:document.write('!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;' +
 document.getElementsByTagName('html')[0].innerHTML);
 
 However, I'm not sure it will fire any validation events, since
 technically the page has already been loaded (Javascript is just adding
 more text). I fear the case will be the same if the current page's
 source is sent to a new browser window.
 
 I'm not asking for any coding suggestions, necessarily--just curious as
 to whether or not anyone knew if this will invoke browser validation
 events or not. Comments and questions are more than welcome, though. :)

Can't you do it via PHP using a GET parameter? Seems more likely to work
properly since it requires the page be reloaded on a fresh slate. While
at the same time, it will easily jump through the doctypes that the
server deems suitable given the parameter

http://www.www.www/foo.php?doctype=xmlstrict1.0

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



RE: [PHP] Javascript question

2009-03-02 Thread Boyd, Todd M.
 -Original Message-
 From: Robert Cummings [mailto:rob...@interjinn.com]
 Sent: Monday, March 02, 2009 4:18 PM
 To: Boyd, Todd M.
 Cc: PHP General list
 Subject: Re: [PHP] Javascript question
 
 On Mon, 2009-03-02 at 16:11 -0600, Boyd, Todd M. wrote:
  Before some of you newbies feel like being heroes and jump all over
 me:
 
  I KNOW THIS IS A PHP-RELATED LIST. IF YOU DON'T LIKE MY QUESTION,
 DON'T
  ANSWER IT.
 
  Now that that's out of the way... I have a Javascript question (and
  maybe a Browser/DOM question) for you folks. I'm not sure this is
  anything they teach you in any online/in-seat/self-taught Javascript
  course that I've ever seen before, so I figured I would bring it
 here.
 
  My boss asked me if I knew of a tool that would change the
!DOCTYPE
 of
  a page on-the-fly to test validation in different schemes (i.e.,
 XHTML
  Strict, Transitional, Loose, etc.). After a bit of looking around,
 this
  is the solution I came up with (as a bookmarklet):
 
  javascript:document.write('!DOCTYPE html PUBLIC -//W3C//DTD XHTML
 1.0
  Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;' +
  document.getElementsByTagName('html')[0].innerHTML);
 
  However, I'm not sure it will fire any validation events, since
  technically the page has already been loaded (Javascript is just
 adding
  more text). I fear the case will be the same if the current page's
  source is sent to a new browser window.
 
  I'm not asking for any coding suggestions, necessarily--just curious
 as
  to whether or not anyone knew if this will invoke browser validation
  events or not. Comments and questions are more than welcome, though.
 :)
 
 Can't you do it via PHP using a GET parameter? Seems more likely to
 work
 properly since it requires the page be reloaded on a fresh slate.
While
 at the same time, it will easily jump through the doctypes that the
 server deems suitable given the parameter
 
 http://www.www.www/foo.php?doctype=xmlstrict1.0

Rob,

Absolutely. However, requiring a server-side script was something I was
hoping to avoid. It may be useful as an intranet utility somewhere down
the road, but a bookmarklet was what I was shooting for for this first
test.

Great minds think alike, eh? :)


// Todd

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



RE: [PHP] Javascript question

2009-03-02 Thread Boyd, Todd M.
 -Original Message-
 From: Michael A. Peters [mailto:mpet...@mac.com]
 Sent: Monday, March 02, 2009 4:42 PM
 To: Boyd, Todd M.
 Cc: PHP General list
 Subject: Re: [PHP] Javascript question
 
 Boyd, Todd M. wrote:
  Before some of you newbies feel like being heroes and jump all over
 me:
 
  I KNOW THIS IS A PHP-RELATED LIST. IF YOU DON'T LIKE MY QUESTION,
 DON'T
  ANSWER IT.
 
  Now that that's out of the way... I have a Javascript question (and
  maybe a Browser/DOM question) for you folks. I'm not sure this is
  anything they teach you in any online/in-seat/self-taught Javascript
  course that I've ever seen before, so I figured I would bring it
 here.
 
  My boss asked me if I knew of a tool that would change the
!DOCTYPE
 of
  a page on-the-fly to test validation in different schemes (i.e.,
 XHTML
  Strict, Transitional, Loose, etc.).
 
 The validators generally don't trigger javascript.
 
 I use DOMDocument to create a valid xhtml page and then before sending
 it to the browser - if the browser does not report accepting valid
 xhtml
 (or I specify I want html) it filters the page to valid html 4.01.
 
 That's probably what you want to do - code for valid xhtml and filter
 the output to other DTD's you want to make available server side
rather
 than trying to use JS to alter the DOCTYPE.
 
 Remember, the proper header to send also relies on the DOCTYPE so if
 you
 sent a header for xhtml but send html (or vice versa) you are still
 breaking the standard regardless of how pristine your output is.
 
 Another advantage to building the document ahead of time and doing any
 translations server side is you can also filter the output for XSS in
 case you missed validating some input.

I think you guys are missing the point--this is not for proprietary use
on our own server with our own pages. I wanted to write a bookmarklet
that would work for any page, on any server. I'm beginning to think
that's not necessarily possible (using just JS and the browser).

Thanks for all of your suggestions, anyway. :)


// Todd

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



Re: [PHP] Javascript question

2009-03-02 Thread Michael A. Peters

Boyd, Todd M. wrote:

Before some of you newbies feel like being heroes and jump all over me:

I KNOW THIS IS A PHP-RELATED LIST. IF YOU DON'T LIKE MY QUESTION, DON'T
ANSWER IT.

Now that that's out of the way... I have a Javascript question (and
maybe a Browser/DOM question) for you folks. I'm not sure this is
anything they teach you in any online/in-seat/self-taught Javascript
course that I've ever seen before, so I figured I would bring it here.

My boss asked me if I knew of a tool that would change the !DOCTYPE of
a page on-the-fly to test validation in different schemes (i.e., XHTML
Strict, Transitional, Loose, etc.).


The validators generally don't trigger javascript.

I use DOMDocument to create a valid xhtml page and then before sending 
it to the browser - if the browser does not report accepting valid xhtml 
(or I specify I want html) it filters the page to valid html 4.01.


That's probably what you want to do - code for valid xhtml and filter 
the output to other DTD's you want to make available server side rather 
than trying to use JS to alter the DOCTYPE.


Remember, the proper header to send also relies on the DOCTYPE so if you 
sent a header for xhtml but send html (or vice versa) you are still 
breaking the standard regardless of how pristine your output is.


Another advantage to building the document ahead of time and doing any 
translations server side is you can also filter the output for XSS in 
case you missed validating some input.


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



[PHP] PHP Javascript header

2009-01-15 Thread Applejus

Hello there,

Kind of newbie to PHP and javascript... I have this problem:

I want to pass a javascript variable to a PHP code.
I am inside a javascript function that is creating HTML elements
dynamically. After creating a select tag, I want to populate it with a
list of variable names from $_SESSION['subgroupcolumn'] .
Here is part of the code:

.
.
.
location.href=subgroup.php?m= + m;
var linner= for ($c=1; $c  $_SESSION['rows']; $c++){ echo( 'option
value=' . $c . '' . $_SESSION['subgroupcolumn'][$c][0] . '/option\n' );
} ;
document.getElementById(selectedSubsetText + hitcounter).innerHTML = linner
;
.
.
.
Since we cannot pass a javascript var to PHP directly, I am redirecting to
subgroup.php and sending the variable (m) and getting it there using a
$_GET. Now the question: 
In subgroup.php, after I get the variable m, I create the
$_SESSION['subgroupcolumn'] array then I redirect to the initial page.
Obviously it's not working because the code after
location.href=subgroup.php?m= + m; is not executing after coming back to
the initial page

How do I make it to continue executing the javascript code?

I hope it's clear...

Thanks for your help.


-- 
View this message in context: 
http://www.nabble.com/PHP-Javascript-header-tp21483721p21483721.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] PHP Javascript header

2009-01-15 Thread Shawn McKenzie
Applejus wrote:
 Hello there,
 
 Kind of newbie to PHP and javascript... I have this problem:
 
 I want to pass a javascript variable to a PHP code.
 I am inside a javascript function that is creating HTML elements
 dynamically. After creating a select tag, I want to populate it with a
 list of variable names from $_SESSION['subgroupcolumn'] .
 Here is part of the code:
 
 .
 .
 .
 location.href=subgroup.php?m= + m;
 var linner= for ($c=1; $c  $_SESSION['rows']; $c++){ echo( 'option
 value=' . $c . '' . $_SESSION['subgroupcolumn'][$c][0] . '/option\n' );
 } ;
 document.getElementById(selectedSubsetText + hitcounter).innerHTML = linner
 ;
 .
 .
 .
 Since we cannot pass a javascript var to PHP directly, I am redirecting to
 subgroup.php and sending the variable (m) and getting it there using a
 $_GET. Now the question: 
 In subgroup.php, after I get the variable m, I create the
 $_SESSION['subgroupcolumn'] array then I redirect to the initial page.
 Obviously it's not working because the code after
 location.href=subgroup.php?m= + m; is not executing after coming back to
 the initial page
 
 How do I make it to continue executing the javascript code?
 
 I hope it's clear...
 
 Thanks for your help.
 
 

The problem is that you are changing the location of the page and then
chaning the location back.  Really you need an AJAX call using
XMLHttpRequest.  There are probably easier examples, but here is one:

http://www.w3schools.com/PHP/php_ajax_suggest.asp

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] table mixing PHP, javascript, ajax and CSS

2008-12-28 Thread Alain Roger
Hi,

i'm currently working on some project which needs in several pages, a table
to display query results...till now nothing special.
however, in order to not create several time the table and features i've
decided to create my own templates including PHP classes, CSS and
javascript.

this table class should have filter, colors schemes, multi selection and
header/paging header.
I would like to know what are your suggestions, recommendations or tips to
have something easy to deploy and upgrade ?

i was thinking to have a common (framework) base : a simple html file having
3 divs, each div receiving a particular php file (header, pagin, or the
table itself)
header, paging or table PHP files could be located in some folder being
different for each template... main changes in templates are usually for the
table it self (in terms of columns amount, of presented data record,...)

basically my structure is the following one:
/folder_to_include_by_user_in_his_development_environment
   /templates
  /template1
 pager.php
 table.php
  /template2
 pager.php
 table.php
  header.php
   frame.php
   /class
  table_class.php
  helping_classes.php
  ...
   /js_and_ajax
 function.js

the user will have only to run a js function which will include the
frame.php file into his own webpage with the template given as parameter.

thx for any suggestion.

-- 
Alain
---
Windows XP x64 SP2 / Fedora 10 KDE 4.2
PostgreSQL 8.3.5 / MS SQL server 2005
Apache 2.2.10
PHP 5.2.6
C# 2005-2008


Re: [PHP] table mixing PHP, javascript, ajax and CSS

2008-12-28 Thread Benjamin Hawkes-Lewis

On 28/12/08 13:33, Alain Roger wrote:


i'm currently working on some project which needs in several pages, a table
to display query results...till now nothing special.
however, in order to not create several time the table and features i've
decided to create my own templates including PHP classes, CSS and
javascript.

this table class should have filter, colors schemes, multi selection and
header/paging header.


An appropriate set of classes (data types, field names, even/odd 
designators for zebra styling) plus CSS is everything you need for color 
schemes.


Can you elaborate on what you mean by multi selection and paging header?


I would like to know what are your suggestions, recommendations or tips to
have something easy to deploy and upgrade ?


I'd look into:

http://developer.yahoo.com/yui/datatable/

It includes filtering.

I usually write my own code for generating raw table markup - that could 
be used by as a progressive enhancement by YUI datatable - with a 
minimum of repetition.


http://www.webaim.org/techniques/tables/data.php has information about 
what constitutes good markup for data tables.



i was thinking to have a common (framework) base : a simple html file having
3 divs, each div receiving a particular php file (header, pagin, or the
table itself)
header, paging or table PHP files could be located in some folder being
different for each template... main changes in templates are usually for the
table it self (in terms of columns amount, of presented data record,...)

the user will have only to run a js function which will include the
frame.php file into his own webpage with the template given as parameter.


The use of JS as an include mechanism is largely pernicious. Couldn't 
they just use include()?


--
Benjamin Hawkes-Lewis

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



[PHP] Javascript mailing list

2008-08-30 Thread Richard Heyes
Hi,

Can anyone recommend a good Javascript related mailing list?

Thanks.

-- 
Richard Heyes

HTML5 Graphing:
http://www.phpguru.org/RGraph

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



Re: [PHP] Javascript mailing list

2008-08-30 Thread Benjamin Hawkes-Lewis

Richard Heyes wrote:

Can anyone recommend a good Javascript related mailing list?


http://lists.evolt.org/mailman/listinfo/javascript perhaps.

--
Benjamin Hawkes-Lewis


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



Re: [PHP] Javascript mailing list

2008-08-30 Thread mike
look at jquery - it will make working with javascript so much easier
and has it's own community around it too.

On 8/30/08, Richard Heyes [EMAIL PROTECTED] wrote:
 Hi,

 Can anyone recommend a good Javascript related mailing list?

 Thanks.

 --
 Richard Heyes

 HTML5 Graphing:
 http://www.phpguru.org/RGraph

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



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



Re: [PHP] Javascript mailing list

2008-08-30 Thread Shiplu
May be jsninja has mailing list.
I am fond of jquery. so i recommend it too.
-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu


[PHP] Javascript control on Firefox 2/3 with flash 9

2008-05-29 Thread jencisson

my page include some javascript to control the play,rewind..and other functions 
of the swffile showEdit.swf, it works in Safari/IE with flash-plugin 8/9 
installed but  not works in Firefox  with flash plugin 9(would reports 
obj.play() is not a function, is any one point out what is the problem or there 
are techniques i can use?

the source codes
script
function show(){
 var obj=document.getElements(showEdit);//it works in Firefox
 obj.play();//it works in IE,but not in Firefox.
}
/script

  object classid=clsid:D27CDB6E-AE6D-11cf-96B8-44455354 
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0;
 width=202 height=498 id=showEdit
param name=movie value=flash/show_edit.swf /
param name=quality value=high /
param name=allowScriptAccess value=sameDomain /
param name=FlashVars value=userid=rasy /
param name=name value=FlashVars /
embed src=flash/show_edit.swf width=202 height=498 quality=hight 
pluginspage=http://www.macromedia.com/go/getflashplayer; 
type=application/x-shockwave-flash allowscriptAccess=sameDomain 
FlashVars=userid=rasy name=FlashVars name=showEdit
/embed
  /object

_
多个邮箱同步管理,live mail客户端万人抢用中
http://get.live.cn/product/mail.html

Re: [PHP] Javascript control on Firefox 2/3 with flash 9

2008-05-29 Thread Wolf

 [EMAIL PROTECTED] wrote: 
 
 my page include some javascript to control the play,rewind..and other 
 functions of the swffile showEdit.swf, it works in Safari/IE with 
 flash-plugin 8/9 installed but  not works in Firefox  with flash plugin 
 9(would reports obj.play() is not a function, is any one point out what is 
 the problem or there are techniques i can use?
 
 the source codes
 script
 function show(){
  var obj=document.getElements(showEdit);//it works in Firefox
  obj.play();//it works in IE,but not in Firefox.
 }
 /script

Sure, GO CHECK WITH A JAVASCRIPT LIST!

There is no PHP code anywhere here.

HTH,
Wolf


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



RE: [PHP] JavaScript and PHP

2008-05-16 Thread Ford, Mike
On 14 May 2008 21:21, tedd advised:

 At 7:31 PM +0100 5/14/08, Mário Gamito wrote:
 Hi,
 
 I have this HTML/JS page that switches images
 clicking on the radio buttons and call
 template.php with the image ID as parameter:
 http://portulan-online.net/einstein.html
 
 Now, I need to make it a PHP page, because it is
 going to receive a parameter from the URL that
 calls it and pass it as is to template.php
 
 Mário:
 
 The key here to remember is that javascript uses
 ID and php uses NAME for inputs.

That's incorrect.  A form will function perfectly well with only name= 
attributes, and no ids, and it's quite possible for JavaScript to address the 
form elements using only the names (in fact, it's easier than via the ids as 
there's a short syntax for it!).

CSS and the DOM, however, use the ids as primary identifier, so use of either 
of those may demand the presence of ids.

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] JavaScript and PHP

2008-05-16 Thread Boyd, Todd M.
 -Original Message-

8 snip!

 That's incorrect.  A form will function perfectly well with only name=
 attributes, and no ids, and it's quite possible for JavaScript to
 address the form elements using only the names (in fact, it's easier
 than via the ids as there's a short syntax for it!).
 
 CSS and the DOM, however, use the ids as primary identifier, so use of
 either of those may demand the presence of ids.

8 snip!

True, you can access an input named myInput in a form named myForm
by simply writing:

document.myForm.myInput.value = Hello!;

BUT... for CSS, it's also quite easy to reference something by name:

[name=myElement]
{
color: blue;
font-size: 10pt;
}


Todd Boyd
Web Programmer

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



RE: [PHP] JavaScript and PHP

2008-05-16 Thread Ford, Mike
On 16 May 2008 16:12, Boyd, Todd M. advised:

 -Original Message-
 
 8 snip!
 
 That's incorrect.  A form will function perfectly well with only
name=
 attributes, and no ids, and it's quite possible for JavaScript to
 address the form elements using only the names (in fact, it's easier
 than via the ids as there's a short syntax for it!).
 
 CSS and the DOM, however, use the ids as primary identifier, so use
of
 either of those may demand the presence of ids.
 
 8 snip!
 
 True, you can access an input named myInput in a form named myForm
by
 simply writing: 
 
   document.myForm.myInput.value = Hello!;
 
 BUT... for CSS, it's also quite easy to reference something by name:
 
   [name=myElement]
   {
   color: blue;
   font-size: 10pt;
   }

Well, true -- hence the qualifiers in *primary* identifier and *may*
demand!

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] JavaScript and PHP

2008-05-16 Thread tedd

At 4:01 PM +0100 5/16/08, Ford, Mike wrote:

On 14 May 2008 21:21, tedd advised:


 At 7:31 PM +0100 5/14/08, Mário Gamito wrote:

 Hi,

 I have this HTML/JS page that switches images
 clicking on the radio buttons and call
 template.php with the image ID as parameter:
 http://portulan-online.net/einstein.html

 Now, I need to make it a PHP page, because it is
 going to receive a parameter from the URL that
 calls it and pass it as is to template.php


 Mário:

 The key here to remember is that javascript uses
 ID and php uses NAME for inputs.


That's incorrect.  A form will function 
perfectly well with only name= attributes, and 
no ids, and it's quite possible for JavaScript 
to address the form elements using only the 
names (in fact, it's easier than via the ids as 
there's a short syntax for it!).


Incorrect or not, it works.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] JavaScript and PHP

2008-05-14 Thread Mário Gamito

Hi,

I have this HTML/JS page that switches images clicking on the radio 
buttons and call template.php with the image ID as parameter: 
http://portulan-online.net/einstein.html


Now, I need to make it a PHP page, because it is going to receive a 
parameter from the URL that calls it and pass it as is to template.php



So, einstein.php will be called with a parameter (satellite): 
http://portulan-online.net/einstein.php?satellite=123


After that, in einstein.php, I do:

$satellite = $_REQUEST['satellite'];

Next thing, I need the action in the JavaScript to be, for example:
http://portulan-online.net/template.php?id=3satellite=123

What I don't know is how to mix the PHP variable satellite with the 
image ID here:
document.getElementById('image1').src = 
http://portulan-online.net/einstein-; + ID + .png;


I've tried putting einstein.php all inside an echo, but the radio 
buttons and the submit button stopped working.


Does anyone knows how to do this ?

Any help would be appreciated.

Warm Regards,
Mário Gamito

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



Re: [PHP] JavaScript and PHP

2008-05-14 Thread Dan Joseph
On Wed, May 14, 2008 at 2:31 PM, Mário Gamito [EMAIL PROTECTED] wrote:

 Hi,

 I have this HTML/JS page that switches images clicking on the radio buttons
 and call template.php with the image ID as parameter:
 http://portulan-online.net/einstein.html

 Now, I need to make it a PHP page, because it is going to receive a
 parameter from the URL that calls it and pass it as is to template.php


 So, einstein.php will be called with a parameter (satellite):
 http://portulan-online.net/einstein.php?satellite=123

 After that, in einstein.php, I do:

 $satellite = $_REQUEST['satellite'];

 Next thing, I need the action in the JavaScript to be, for example:
 http://portulan-online.net/template.php?id=3satellite=123

 What I don't know is how to mix the PHP variable satellite with the image
 ID here:
 document.getElementById('image1').src = 
 http://portulan-online.net/einstein-; + ID + .png;

 I've tried putting einstein.php all inside an echo, but the radio buttons
 and the submit button stopped working.

 Does anyone knows how to do this ?

 Any help would be appreciated.

 Warm Regards,
 Mário Gamito

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


document.getElementById('image1').src = 
http://portulan-online.net/einstein-; + ?php echo $_GET['satellite']; ? +
.png;

You could do that.  Also, I'd suggest using $_GET instead of $_REQUEST.
Request works,b ut it is very broad.  $_GET is more specific/secure.


-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month. Reseller plans and
Dedicated servers available.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


Re: [PHP] JavaScript and PHP

2008-05-14 Thread tedd

At 7:31 PM +0100 5/14/08, Mário Gamito wrote:

Hi,

I have this HTML/JS page that switches images 
clicking on the radio buttons and call 
template.php with the image ID as parameter: 
http://portulan-online.net/einstein.html


Now, I need to make it a PHP page, because it is 
going to receive a parameter from the URL that 
calls it and pass it as is to template.php


Mário:

The key here to remember is that javascript uses 
ID and php uses NAME for inputs. So, if you put 
your variables in that form and they will work 
between javascript and php. Such as:


input type=radio name=rad id=rad value=2 
onclick=javascript:GetImage(this);Einstein 2


Note the change of this in your js call -- you 
can do that and not have to provide the number.


Also put in an action=whatever into your form 
and collect the selection via $_POST['rad'];


That will do what you want.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] OT Re: [PHP] javascript in head or in body ?

2007-08-13 Thread Daniel Brown
On 8/12/07, tedd [EMAIL PROTECTED] wrote:
 For example, if your wife says (and you're not listening as usual)
 Do these pants make my butt look big? Neither answer is going to
 help much. But, if said separately, you at least have a chance of
 surviving the ordeal.

And I'll also point out that they will work in either order in
most cases - including the one Tedd gave as an example.  To
demonstrate:

Do these pants make my butt look big?
Yes, dear.
WHAT?!?
I'm sorry!

- or -

Do this pants make my butt look big?
I'm sorry yes, dear.

However, note that it is NEVER alright to say one of the following:
No, your fat ass makes it look big.
No, but that second piece of cheesecake did.
Hell yeah!
How the hell did you pull those up?
I didn't want to say anything, but that's why I always want to be on top.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] javascript in head or in body ?

2007-08-12 Thread David Robley
tedd wrote:

 At 9:29 PM +0200 8/7/07, Tijnema wrote:
On 8/7/07, Robert Cummings [EMAIL PROTECTED] wrote:
   Yeah!! This list is for public apologies and Copyright discussion.

  Cheers,
  Rob.
  --

Oh yeah, Tedd is only the first of thousands of people that need to
apologize... :P

Tijnema
 
 
 Ah crap, have I got something else to apologize for?
 
 At this rate, by the time I reach the end of my life, I'll know only
 two sentences, namely I'm sorry and Yes, Dear.

Seems to me you could rather easily condense that to just one sentence with
the same degree of functionality. :-)




Cheers
-- 
David Robley

This isn't hell, but I can see it from here.
Today is Prickle-Prickle, the 5th day of Bureaucracy in the YOLD 3173. 
Celebrate Zaraday

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



Re: [PHP] javascript in head or in body ?

2007-08-12 Thread tedd

At 1:26 PM -0400 8/11/07, Robert Cummings wrote:

On Sat, 2007-08-11 at 12:15 -0400, tedd wrote:
  Always (fishing for another apology opportunity) place javascript in

 external files and call them in via the header. Keep the code
 unobtrusive. There are ways to use javascript without having to mix
 it into your html -- look up DOM scripting.


I absolutely agree with unobtrusive JavaScript, but I do disagree with
you slightly on using external files. Generally speaking i keep large
bits of code (Especially libs) in external files, but a few lines of
script for a form that appears on one page I'll often be put in the head
section. This way the JavaScript is in the same file as the template for
which it is associated. My template engine will relocate the JavaScript
to the head section at compile time.


That's clever. I assume that for production work (i.e., for a 
client), you can isolate the files you need and be totally 
unobtrusive if you want.


I just described my method off-list to another person and it went like this:

I have a system for my site development work such that I simply 
include one header and one footer and no matter where the project 
directory is that I'm currently working on, the process will find the 
one main common header and common footer and will add them to my demo 
automagically.


My code to start, looks like this:

?php include('../header.php') ?
   h1 Hi /h1
?php include('../footer.php') ?

From there I have a complete page -- from doctype to copyright, it's 
all there and it validates.


If I need a javascript file locally, then I add it to the local 
working directory by naming the file a.js. Likewise, if I need an 
additional css file, then I name it a.css and it's also included in 
the call.


However, if I don't need those files, then none are included in my 
local working directory and attempts to load those files will fail -- 
however -- it doesn't matter if an attempt to load fails or not as 
long as the files are not needed.


I think that's kind of clever, but I like Rocky and Bullwinkle as well.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] OT Re: [PHP] javascript in head or in body ?

2007-08-12 Thread tedd

At 10:21 PM +0930 8/12/07, David Robley wrote:

tedd wrote:

 

 At this rate, by the time I reach the end of my life, I'll know only
 two sentences, namely I'm sorry and Yes, Dear.


Seems to me you could rather easily condense that to just one sentence with
the same degree of functionality. :-)



Unfortunately, it doesn't work that way. You must keep them in two 
separate sentences.


For example, if your wife says (and you're not listening as usual) 
Do these pants make my butt look big? Neither answer is going to 
help much. But, if said separately, you at least have a chance of 
surviving the ordeal.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] javascript in head or in body ?

2007-08-12 Thread Robert Cummings
On Sun, 2007-08-12 at 21:27 -0400, tedd wrote:
 At 1:26 PM -0400 8/11/07, Robert Cummings wrote:
 On Sat, 2007-08-11 at 12:15 -0400, tedd wrote:
Always (fishing for another apology opportunity) place javascript in
   external files and call them in via the header. Keep the code
   unobtrusive. There are ways to use javascript without having to mix
   it into your html -- look up DOM scripting.
 
 I absolutely agree with unobtrusive JavaScript, but I do disagree with
 you slightly on using external files. Generally speaking i keep large
 bits of code (Especially libs) in external files, but a few lines of
 script for a form that appears on one page I'll often be put in the head
 section. This way the JavaScript is in the same file as the template for
 which it is associated. My template engine will relocate the JavaScript
 to the head section at compile time.
 
 That's clever. I assume that for production work (i.e., for a 
 client), you can isolate the files you need and be totally 
 unobtrusive if you want.
 
 I just described my method off-list to another person and it went like this:
 
 I have a system for my site development work such that I simply 
 include one header and one footer and no matter where the project 
 directory is that I'm currently working on, the process will find the 
 one main common header and common footer and will add them to my demo 
 automagically.
 
 My code to start, looks like this:
 
 ?php include('../header.php') ?
 h1 Hi /h1
 ?php include('../footer.php') ?
 
  From there I have a complete page -- from doctype to copyright, it's 
 all there and it validates.
 
 If I need a javascript file locally, then I add it to the local 
 working directory by naming the file a.js. Likewise, if I need an 
 additional css file, then I name it a.css and it's also included in 
 the call.
 
 However, if I don't need those files, then none are included in my 
 local working directory and attempts to load those files will fail -- 
 however -- it doesn't matter if an attempt to load fails or not as 
 long as the files are not needed.
 
 I think that's kind of clever, but I like Rocky and Bullwinkle as well.

I don't use a script to find my JavaScript files and CSS but I do
something similar to your includes for header and footer. The difference
being that my template engine will pull them in at compile time and not
at run-time. A lot of static content is pulled in this way and relocated
using compile-time accumulators. Then I use run-time accumulators to
flush content at run-time into the appropriate areas if necessary. This
allows me to create a layout that is compiled once at compile time but
with flush hooks for run-time. For instance for simplicity I use the
following tag in the head area to set up JavaScript:

jinn:javaScriptSystem/

This is the same as doing the following manually:


jinn:accumulatorFlush name=javaScriptTags/
jinn:accumulatorFlush name=javaScriptTags dynamic=true/

jinn:javaScript
jinn:accumulatorFlush name=javaScript/
jinn:accumulatorFlush name=javaScript dynamic=true/

function javaScriptOnLoad()
{
jinn:accumulatorFlush name=javaScriptOnLoad/
jinn:accumulatorFlush name=javaScriptOnLoad dynamic=true/
}

/jinn:javaScript
-

The body tag will have an onload=javaScriptOnLoad(). Then in a content
file I can add the following:

jinn:accumulate name=javaScriptOnLoad

// some javascript code to modify the DOM

/jinn:accumulate

And it will get relocated at compile time to the location of the static
flush statement: jinn:accumulatorFlush name=javaScriptOnLoad/

Similarly within my code at run-time I can do the following:

$mAcc = $this-getServiceRef( 'accManager' );
$acc = $mAcc-getRef( 'javaScriptOnLoad' );

$acc-append
(
' // some javascript to modify the DOM '
)

And it will be get flushed into the content at the location of the
dynamic flush statement:

jinn:accumulatorFlush name=javaScriptOnLoad dynamic=true/

So all in all, it's very simple for me to put JavaScript (and any
content for that matter) anywhere I please. I often use it for layout
areas (such as left pane, right pane, etc), menus, visitor notices, etc.

BTW if you're wondering why I have a jinn:javaScript tag it's because
who wants to remember the following:

---
script type=text/javascript!--//--![CDATA[//!--

//--!]]/script
---

:)

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] javascript in head or in body ?

2007-08-11 Thread tedd

At 9:29 PM +0200 8/7/07, Tijnema wrote:

On 8/7/07, Robert Cummings [EMAIL PROTECTED] wrote:
  Yeah!! This list is for public apologies and Copyright discussion.


 Cheers,
 Rob.
 --


Oh yeah, Tedd is only the first of thousands of people that need to
apologize... :P

Tijnema



Ah crap, have I got something else to apologize for?

At this rate, by the time I reach the end of my life, I'll know only 
two sentences, namely I'm sorry and Yes, Dear.


Oh, to bring this off-topic question back to on-topic (?)

Always (fishing for another apology opportunity) place javascript in 
external files and call them in via the header. Keep the code 
unobtrusive. There are ways to use javascript without having to mix 
it into your html -- look up DOM scripting.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] javascript in head or in body ?

2007-08-11 Thread Robert Cummings
On Sat, 2007-08-11 at 12:15 -0400, tedd wrote:
 At 9:29 PM +0200 8/7/07, Tijnema wrote:
 On 8/7/07, Robert Cummings [EMAIL PROTECTED] wrote:
Yeah!! This list is for public apologies and Copyright discussion.
 
   Cheers,
   Rob.
   --
 
 Oh yeah, Tedd is only the first of thousands of people that need to
 apologize... :P
 
 Tijnema
 
 
 Ah crap, have I got something else to apologize for?
 
 At this rate, by the time I reach the end of my life, I'll know only 
 two sentences, namely I'm sorry and Yes, Dear.
 
 Oh, to bring this off-topic question back to on-topic (?)
 
 Always (fishing for another apology opportunity) place javascript in 
 external files and call them in via the header. Keep the code 
 unobtrusive. There are ways to use javascript without having to mix 
 it into your html -- look up DOM scripting.

I absolutely agree with unobtrusive JavaScript, but I do disagree with
you slightly on using external files. Generally speaking i keep large
bits of code (Especially libs) in external files, but a few lines of
script for a form that appears on one page I'll often be put in the head
section. This way the JavaScript is in the same file as the template for
which it is associated. My template engine will relocate the JavaScript
to the head section at compile time.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



[PHP] javascript in head or in body ?

2007-08-07 Thread C.R.Vegelin
Are there any rules when to include javascript in head or in body ?
For example, 
script type=text/javascript
function reload(form)
{  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value; 
   self.location='QueryForm.php?Chapter=' + val ;
}
/script

TIA, Cor


Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Tijnema
On 8/7/07, C.R.Vegelin [EMAIL PROTECTED] wrote:
 Are there any rules when to include javascript in head or in body ?
 For example,
 script type=text/javascript
 function reload(form)
 {  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value;
   self.location='QueryForm.php?Chapter=' + val ;
 }
 /script

 TIA, Cor


Uhh, do you know which list this is?

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Greg Donald
On 8/7/07, C.R.Vegelin [EMAIL PROTECTED] wrote:
 Are there any rules when to include javascript in head or in body ?
 For example,
 script type=text/javascript
 function reload(form)
 {  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value;
self.location='QueryForm.php?Chapter=' + val ;
 }
 /script

w3 says it can appear in either:

snip
The SCRIPT element places a script within a document. This element may
appear any number of times in the HEAD or BODY of an HTML document.
/snip

http://www.w3.org/TR/html4/interact/scripts.html#h-18.1


-- 
Greg Donald
http://destiney.com/

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Robert Cummings
On Tue, 2007-08-07 at 21:24 +0200, Tijnema wrote:
 On 8/7/07, C.R.Vegelin [EMAIL PROTECTED] wrote:
  Are there any rules when to include javascript in head or in body ?
  For example,
  script type=text/javascript
  function reload(form)
  {  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value;
self.location='QueryForm.php?Chapter=' + val ;
  }
  /script
 
  TIA, Cor
 
 
 Uhh, do you know which list this is?

Yeah!! This list is for public apologies and Copyright discussion.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Tijnema
On 8/7/07, Robert Cummings [EMAIL PROTECTED] wrote:
 On Tue, 2007-08-07 at 21:24 +0200, Tijnema wrote:
  On 8/7/07, C.R.Vegelin [EMAIL PROTECTED] wrote:
   Are there any rules when to include javascript in head or in body ?
   For example,
   script type=text/javascript
   function reload(form)
   {  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value;
 self.location='QueryForm.php?Chapter=' + val ;
   }
   /script
  
   TIA, Cor
  
 
  Uhh, do you know which list this is?

 Yeah!! This list is for public apologies and Copyright discussion.

 Cheers,
 Rob.
 --

Oh yeah, Tedd is only the first of thousands of people that need to
apologize... :P

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Richard Heyes

C.R.Vegelin wrote:

Are there any rules when to include javascript in head or in body ?
For example, 
script type=text/javascript

function reload(form)
{  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value; 
   self.location='QueryForm.php?Chapter=' + val ;

}
/script


Either really. Both work.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread brian

C.R.Vegelin wrote:

Are there any rules when to include javascript in head or in body ?
For example, 
script type=text/javascript

function reload(form)
{  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value; 
   self.location='QueryForm.php?Chapter=' + val ;

}
/script



Generally, script blocks outside of the head are meant to be used for 
routines that run as the page is loading. For example, one might have 
some JS that creates some block of HTML or something. Or one might have 
a JS block at the very end of the page that is meant to run once the 
page has (almost) completed loading. Why people do this, i'm not sure. 
Personally, i think script blocks belong in the head. If you have some 
function that needs to run at page load, there's the onload handler for 
that.


In your case, it looks like that function could be placed pretty much 
anywhere, as it can only be called once the page has loaded, anyway. Is 
your problem that you can't change the head of the page (to include that 
function) for some reason? In any case, go ahead and put it in the body.


brian

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Greg Donald
On 8/7/07, Tijnema [EMAIL PROTECTED] wrote:
 Uhh, do you know which list this is?

I give up..  Is it the one where I get as many [OT] labeled emails as
I do on-topic ones?

People have been asking basic html questions here for (over?) a
decade, and it probably won't stop anytime soon.  Newcomers don't know
it's wrong because they haven't seen anyone be smacked down for it.
So until you can smack someone down in advance, it won't stop.

It's not that big a deal is it?  I mean html discussion isn't nearly
as important as a heated copyright law debate, but then my delete
button works great.

I think you just want something to bitch about.


-- 
Greg Donald
http://destiney.com/

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Jason Pruim


On Aug 7, 2007, at 3:29 PM, Tijnema wrote:


On 8/7/07, Robert Cummings [EMAIL PROTECTED] wrote:

On Tue, 2007-08-07 at 21:24 +0200, Tijnema wrote:

On 8/7/07, C.R.Vegelin [EMAIL PROTECTED] wrote:
Are there any rules when to include javascript in head or in  
body ?

For example,
script type=text/javascript
function reload(form)
{  var val=form.Chapter.options 
[form.Chapter.options.selectedIndex].value;

  self.location='QueryForm.php?Chapter=' + val ;
}
/script

TIA, Cor



Uhh, do you know which list this is?


Yeah!! This list is for public apologies and Copyright discussion.

Cheers,
Rob.
--


Oh yeah, Tedd is only the first of thousands of people that need to
apologize... :P


Later this week on Php-General, witness the revolutionary  
confessions of a PHP Programmer stuck in the middle of a lovers  
triangle of OOP, and Procedural




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Robert Cummings
On Tue, 2007-08-07 at 21:19 +0100, C.R.Vegelin wrote:
 Are there any rules when to include javascript in head or in body ?
 For example, 
 script type=text/javascript
 function reload(form)
 {  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value; 
self.location='QueryForm.php?Chapter=' + val ;
 }
 /script

In head - whenever possible
In body - whenever else

It's not incorrect to have JS in the body, but it sure makes it more
difficult to see what's happening.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Satyam

Check:

http://developer.yahoo.com/performance/rules.html

Satyam

PS:  The answer is, put styles at the top, scripts at the bottom., but there 
are many other tricks to improve performance.  Otherwise, as for the 
standards, they can go anywhere.



- Original Message - 
From: C.R.Vegelin [EMAIL PROTECTED]

To: [EMAIL PROTECTED] php-general@lists.php.net
Sent: Tuesday, August 07, 2007 10:19 PM
Subject: [PHP] javascript in head or in body ?


Are there any rules when to include javascript in head or in body ?
For example,
script type=text/javascript
function reload(form)
{  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value;
  self.location='QueryForm.php?Chapter=' + val ;
}
/script

TIA, Cor






No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 06/08/2007 
16:53


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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Tijnema
On 8/7/07, Richard Heyes [EMAIL PROTECTED] wrote:
 C.R.Vegelin wrote:
  Are there any rules when to include javascript in head or in body ?
  For example,
  script type=text/javascript
  function reload(form)
  {  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value;
 self.location='QueryForm.php?Chapter=' + val ;
  }
  /script

 Either really. Both work.

 --
 Richard Heyes

Actually, I didn't want to answer this, but you're talking shit here ;)

Javascript needs to be initialised before it can be used.
So, if you have a function bodyload(), and you call it from body
onload=bodyload();, you need to place it inside head, as it isn't
loaded if you put it in body.
Some browsers will still run the javascript code, however it is not recommended.

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Tijnema
On 8/7/07, Greg Donald [EMAIL PROTECTED] wrote:
 On 8/7/07, Tijnema [EMAIL PROTECTED] wrote:
  Uhh, do you know which list this is?

 I give up..  Is it the one where I get as many [OT] labeled emails as
 I do on-topic ones?

 People have been asking basic html questions here for (over?) a
 decade, and it probably won't stop anytime soon.  Newcomers don't know
 it's wrong because they haven't seen anyone be smacked down for it.
 So until you can smack someone down in advance, it won't stop.

What about a php-html list? or php-js? :P


 It's not that big a deal is it?  I mean html discussion isn't nearly
 as important as a heated copyright law debate, but then my delete
 button works great.

 I think you just want something to bitch about.

 --
 Greg Donald
 http://destiney.com/

Yep, you're right. This list has quite a lot traffic, and if all
useless topics could move to another list, the real problems could
be handled here, and we could see the forest through the trees again
;) Or however you want to call it in english ;)

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread tg-php
Ok, you got the obligatory 'wrong list' comments.  It is the wrong list, but 
for the sake of public completeness... how about an answer to the question.

You can put it anywhere but a couple of considerations:

1. I believe if you put it AFTER where the JS functions defined in that block 
are called, it may try to call the functions before the functions appear.  So 
close to the top is always good.  I could be wrong on this, but there was some 
kind of condition along those lines and I think it was with JS and positioning.

2. Non JS compliant browsers.  If you put it in the body, they're likely to 
ignore the script tags and just blatantly display the JS as if it was meant 
for output.  This can be mitigated by using HTML comment blocks around the JS. 
Since they're different than JS comment blocks, it won't interfere with the JS. 
 But putting your script in the head block should also prevent it from 
being displayed.

3. If you're executing JS in order to output something, you're going to need to 
put it whereever in your HTML you'll need the output.  If you're just defining 
functions to be called later, then you can put it whereever (probably above 
where you're calling the functions.. see #1).

The only things we don't put in the head for script blocks is a popup 
calendar thing that the old developer installed and our users seem to like.  
Part of it's requirements is a script tag that includes some JS and HTML 
where you want the popup calendar to appear.   Could probably be streamlined, 
but works well enough and doesn't look too ugly so why make more work for 
ourselves until we do the full re-design (2035?)

-TG

= = = Original message = = =

Are there any rules when to include javascript in head or in body ?
For example, 
script type=text/javascript
function reload(form)
  var val=form.Chapter.options[form.Chapter.options.selectedIndex].value; 
   self.location='QueryForm.php?Chapter=' + val ;

/script

TIA, Cor


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Greg Donald
On 8/7/07, Jason Pruim [EMAIL PROTECTED] wrote:
 Later this week on Php-General, witness the revolutionary
 confessions of a PHP Programmer stuck in the middle of a lovers
 triangle of OOP, and Procedural

That's a re-run.  Python wins with Ruby coming in second place.  PHP
gets renamed to Java, etc.


-- 
Greg Donald
http://destiney.com/

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Robert Cummings
On Tue, 2007-08-07 at 15:50 -0400, [EMAIL PROTECTED] wrote:
 
 3. If you're executing JS in order to output something, you're going
 to need to put it whereever in your HTML you'll need the output.  If
 you're just defining functions to be called later, then you can put
 it whereever (probably above where you're calling the functions.. see
 #1).

That's not true. You can still have it in the head and use javascript to
target specific content to a tag with an ID.

In fact, I'd say that's a better option when used in conjunction with
onload() since you can be certain all of your libraries are loaded.
Additionally it allows you to place default content in the event that
your visitor doesn't have JavaScript enabled.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Robert Cummings
On Tue, 2007-08-07 at 14:58 -0500, Greg Donald wrote:
 On 8/7/07, Jason Pruim [EMAIL PROTECTED] wrote:
  Later this week on Php-General, witness the revolutionary
  confessions of a PHP Programmer stuck in the middle of a lovers
  triangle of OOP, and Procedural
 
 That's a re-run.  Python wins with Ruby coming in second place.  PHP
 gets renamed to Java, etc.

Yeah, the numbers really show Python and Ruby winning... NOT *LOL*.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Greg Donald
On 8/7/07, Robert Cummings [EMAIL PROTECTED] wrote:
 Yeah, the numbers really show Python and Ruby winning... NOT *LOL*.

You mean how both Ruby and Python list serv traffic is way up while
PHP's is way down?  Even the PHP dev list is really slowed the past
year or so.. just some guy named Richard bothering them about random
stuff every once in a while, that's about it.  Oh, and the occasional
namespace discussion.  To namespace or not to namespace, who really
cares.

But to clarify the obvious for those without their own clue bat with
which to beat one's self, I was referring to language quality with
regard to OO.  PHP is a cluster-fuck in comparison to pretty much
anything out there.. except maybe Perl's OO.  And go look at PHP SPL,
and tell me that's not Java by another name.

PHP is the absolute worst language to do any sort of OO programming in.


-- 
Greg Donald
http://destiney.com/

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Borokov Smith

Yes. Just yes.

regards,

boro

Greg Donald schreef:

On 8/7/07, Robert Cummings [EMAIL PROTECTED] wrote:
  

Yeah, the numbers really show Python and Ruby winning... NOT *LOL*.



You mean how both Ruby and Python list serv traffic is way up while
PHP's is way down?  Even the PHP dev list is really slowed the past
year or so.. just some guy named Richard bothering them about random
stuff every once in a while, that's about it.  Oh, and the occasional
namespace discussion.  To namespace or not to namespace, who really
cares.

But to clarify the obvious for those without their own clue bat with
which to beat one's self, I was referring to language quality with
regard to OO.  PHP is a cluster-fuck in comparison to pretty much
anything out there.. except maybe Perl's OO.  And go look at PHP SPL,
and tell me that's not Java by another name.

PHP is the absolute worst language to do any sort of OO programming in.


  


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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Robert Cummings
On Tue, 2007-08-07 at 15:52 -0500, Greg Donald wrote:
 On 8/7/07, Robert Cummings [EMAIL PROTECTED] wrote:
  Yeah, the numbers really show Python and Ruby winning... NOT *LOL*.
 
 You mean how both Ruby and Python list serv traffic is way up while
 PHP's is way down?

Way up and way down are trends. Trends may be fads or they may be
sustained cultural changes. Time will tell, but it certainly hasn't told
yet. I hardly consider list serv traffic an indicator of language
superiority... especially when high traffic may be an indicator of bugs.

   Even the PHP dev list is really slowed the past
 year or so.. just some guy named Richard bothering them about random
 stuff every once in a while, that's about it.  Oh, and the occasional
 namespace discussion.  To namespace or not to namespace, who really
 cares.

Those who discuss it *lol*.

 But to clarify the obvious for those without their own clue bat with
 which to beat one's self, I was referring to language quality with
 regard to OO.  PHP is a cluster-fuck in comparison to pretty much
 anything out there.. except maybe Perl's OO.  And go look at PHP SPL,
 and tell me that's not Java by another name.

I dunno, I don't use it. Haven't found a need for it yet.

 PHP is the absolute worst language to do any sort of OO programming in.

That's a very subjective statement. I've had no trouble writing OOP
since PHP3. I like references in PHP4, and it's nice that PHP5 uses
automatic references when assigning objects by value. But that's just
cake icing. OOP is a programming style, not necessarily a language
construct.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re[2]: [PHP] javascript in head or in body ?

2007-08-07 Thread Richard Davey
Hi Greg,

Tuesday, August 7, 2007, 9:52:28 PM, you wrote:

 PHP is the absolute worst language to do any sort of OO programming
 in.

Ignoring the digg user mentality of that statement, try ASP if you
want to see OO suck *royally*

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Stut

Richard Davey wrote:

Tuesday, August 7, 2007, 9:52:28 PM, you wrote:


PHP is the absolute worst language to do any sort of OO programming
in.


Ignoring the digg user mentality of that statement, try ASP if you
want to see OO suck *royally*


ASP is not a language, it's most like a framework. I think you meant VB6.

-Stut

--
http://stut.net/

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Richard Lynch
On Tue, August 7, 2007 3:19 pm, C.R.Vegelin wrote:
 Are there any rules when to include javascript in head or in body
 ?
 For example,
 script type=text/javascript
 function reload(form)
 {  var
 val=form.Chapter.options[form.Chapter.options.selectedIndex].value;
self.location='QueryForm.php?Chapter=' + val ;
 }
 /script

Yes.

But this is a general HTML/Javascript question, and not a PHP question.

The best short answer I can provide is this:

When in doubt, it belongs in head

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] javascript in head or in body ?

2007-08-07 Thread Richard Lynch
On Tue, August 7, 2007 2:48 pm, Tijnema wrote:
 On 8/7/07, Greg Donald [EMAIL PROTECTED] wrote:
 On 8/7/07, Tijnema [EMAIL PROTECTED] wrote:
  Uhh, do you know which list this is?

 I give up..  Is it the one where I get as many [OT] labeled emails
 as
 I do on-topic ones?

 People have been asking basic html questions here for (over?) a
 decade, and it probably won't stop anytime soon.  Newcomers don't
 know
 it's wrong because they haven't seen anyone be smacked down for it.
 So until you can smack someone down in advance, it won't stop.

 What about a php-html list? or php-js? :P

This might drain off some of the not really on topic questions from
newbies who don't understand how the jigsaw puzzle pieces fit
together...

But the number of actual on-topic questions invovling PHP and HTML or
PHP and JS is pretty dang low...

So they'd still be off-topic, just on another list.

And would anybody who knows enough to say they're off-topic even
subscribe?

Or would the lists just sort of wither and die and then we'd just get
the same questions back here again?

PS
As a common courtesy, if you're going to tell somebody they are
off-topic, a recommendation for where it might be on topic or some
indication of what subject matter they ARE talking about would
probably be much more useful than just that's OT!

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Javascript and PHP interaction

2007-03-12 Thread Richard Lynch
What you *COULD* do is this:

Use .htaccess to force your .css files to *really* be PHP files:

Files ~.css
  ForceType application/x-httpd-php
/Files

[NOTE: Depending on your server configuration, the
application/x-httpd-php part could be *ANYTHING* the sysadmin felt was
appropriate...]

Inside your CSS, you now have the full-blown power of PHP to output
whatever you think is right for the CSS.

But you'll need to tell the browser that this *IS* CSS output, so
you'll need:
?php
   header(Content-type: text/css);
?
at the very tip-top.

Note that browsers can cache the CSS, so you'll want to add more
headers to stop that, probably, or have a random value in the LINK tag
in your HTML document.

On Thu, March 8, 2007 3:14 am, Alain Roger wrote:
 Hi,

 I would like to know if there is a way how PHP code can extract from
 ElementID some property values.

 for example, i have the following PHP page :

 ?php
 print div class='maindiv' id='id_maindiv'my main div/div;
 $new_Width = somefunction();
 print div class='childdiv' id='id_childdiv'
 style='width:.$new_Width.px;'my child div/div;
 ?
 in my CSS file (which is link to my HTML page), i have :

 .maindiv
 {
  width : 300px;
  height : 400px;
  background-color : #EEBBEE;
 }
 .childdiv
 {
  background-color : #BB;
 }

 my PHP code should be able :
 - to extract the width of id_maindiv ID (so to get 300px) and to
 reduce it
 by 50px

 the problem is that i tried with Javascript and if the property
 (style:width) is not define DIRECTLY to HTML code (but only in CSS
 file),
 the javascript is not able to return the value (but only 'undefined').
 So i would like to know if PHP could help me in this way ?

 thanks a lot,

 --
 Alain
 
 Windows XP SP2
 PostgreSQL 8.1.4
 Apache 2.0.58
 PHP 5



-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] Javascript and PHP interaction

2007-03-08 Thread Alain Roger

Hi,

I would like to know if there is a way how PHP code can extract from
ElementID some property values.

for example, i have the following PHP page :

?php
print div class='maindiv' id='id_maindiv'my main div/div;
$new_Width = somefunction();
print div class='childdiv' id='id_childdiv'
style='width:.$new_Width.px;'my child div/div;
?
in my CSS file (which is link to my HTML page), i have :

.maindiv
{
width : 300px;
height : 400px;
background-color : #EEBBEE;
}
.childdiv
{
background-color : #BB;
}

my PHP code should be able :
- to extract the width of id_maindiv ID (so to get 300px) and to reduce it
by 50px

the problem is that i tried with Javascript and if the property
(style:width) is not define DIRECTLY to HTML code (but only in CSS file),
the javascript is not able to return the value (but only 'undefined').
So i would like to know if PHP could help me in this way ?

thanks a lot,

--
Alain

Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5


Re: [PHP] Javascript and PHP interaction

2007-03-08 Thread Németh Zoltán
2007. 03. 8, csütörtök keltezéssel 09.14-kor Alain Roger ezt írta:
 Hi,
 
 I would like to know if there is a way how PHP code can extract from
 ElementID some property values.
 
 for example, i have the following PHP page :
 
 ?php
 print div class='maindiv' id='id_maindiv'my main div/div;
 $new_Width = somefunction();
 print div class='childdiv' id='id_childdiv'
 style='width:.$new_Width.px;'my child div/div;
 ?
 in my CSS file (which is link to my HTML page), i have :
 
 .maindiv
 {
  width : 300px;
  height : 400px;
  background-color : #EEBBEE;
 }
 .childdiv
 {
  background-color : #BB;
 }
 
 my PHP code should be able :
 - to extract the width of id_maindiv ID (so to get 300px) and to reduce it
 by 50px
 
 the problem is that i tried with Javascript and if the property
 (style:width) is not define DIRECTLY to HTML code (but only in CSS file),
 the javascript is not able to return the value (but only 'undefined').
 So i would like to know if PHP could help me in this way ?

I think you can not do it with PHP.
But you can do it with javascript. you have to read the offsetWidth
property of the object, then set it's style.width like

if (document.getElementById('whatever').offsetWidth  300) {
document.getElementById('whatever').style.width = 300;
}

hope that helps
Zoltán Németh

 
 thanks a lot,
 

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



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Dan Shirah

Okay, I edited my page per some suggestions here.  Below is what I now have:


script language=JavaScript
function checkForm() {

// ** START **
 if (inputForm.cc_phone_number.value == ) {
   alert( Please enter a phone number. );
   inputForm.cc_phone_number.focus();
   return;
 }

**Lots of other checks here, just left out for length**

  document.inputForm.submit();
}

/script
title/title
LINK rel=stylesheet type=text/css href=../../CSS/background.css
/head
body
div align=center h2/h2
  h3Submit a New Payment./h3
/div
form name=inputForm action=save.php method=post
enctype=multipart/form-data

**Lots of form data here**

table align=center border=0 cellpadding=0 cellspacing=0
width=680
tr
td width=64 align=lefta href=javascript:checkForm()
title=SaveSave/a/td
td width=616 align=lefta href=javascript:closeThis()
title=CloseClose/a/td
/tr
/table
/form
/body
/html

Now when I submit my page it still perfroms all of the javascript checks
correctly, but once it gets to the document.inputForm.submit(); part it
returns the following error.

Error: Object doesn't support this property or method.
Code: 0



On 2/7/07, Paul Novitski [EMAIL PROTECTED] wrote:


At 2/7/2007 01:34 PM, Dan Shirah wrote:
I have a form that uses Javascript to validate form field entries, and if
they are incorrect it returns an error to the user.

After the Javascript processing is complete, it submits the form to my
save
page. However it seems that once the processing is complete and it passes
to
the save page, none of my $_POST variables are being passed.


Of course, all of your form fields need to be inside the same
form/form tags as your submit button.  The sample HTML you posted
did not indicate that you'd done this.

Regards,

Paul
__

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com




Re: [PHP] Javascript and $_POST

2007-02-08 Thread Németh Zoltán
On cs, 2007-02-08 at 08:14 -0500, Dan Shirah wrote:
 Okay, I edited my page per some suggestions here.  Below is what I now have:
 
 
 script language=JavaScript
 function checkForm() {
 
  // ** START **
   if (inputForm.cc_phone_number.value == ) {
 alert( Please enter a phone number. );
 inputForm.cc_phone_number.focus();
 return;
   }
 
 **Lots of other checks here, just left out for length**
 
document.inputForm.submit();
 }
 
 /script
 title/title
 LINK rel=stylesheet type=text/css href=../../CSS/background.css
 /head
 body
 div align=center h2/h2
h3Submit a New Payment./h3
 /div
 form name=inputForm action=save.php method=post
 enctype=multipart/form-data
 
 **Lots of form data here**
 
 table align=center border=0 cellpadding=0 cellspacing=0
 width=680
  tr
  td width=64 align=lefta href=javascript:checkForm()
 title=SaveSave/a/td
  td width=616 align=lefta href=javascript:closeThis()
 title=CloseClose/a/td
  /tr
 /table
 /form
 /body
 /html
 
 Now when I submit my page it still perfroms all of the javascript checks
 correctly, but once it gets to the document.inputForm.submit(); part it
 returns the following error.
 
 Error: Object doesn't support this property or method.
 Code: 0
 

maybe because you don't have submit button in the form?
try to include something like this
input type=image src=./images/spacer.gif
where spacer.gif is an 1x1 blank image

I remember some similar situation where it helped, but I'm not sure

hope that helps
Zoltán Németh

 
 
 On 2/7/07, Paul Novitski [EMAIL PROTECTED] wrote:
 
  At 2/7/2007 01:34 PM, Dan Shirah wrote:
  I have a form that uses Javascript to validate form field entries, and if
  they are incorrect it returns an error to the user.
  
  After the Javascript processing is complete, it submits the form to my
  save
  page. However it seems that once the processing is complete and it passes
  to
  the save page, none of my $_POST variables are being passed.
 
 
  Of course, all of your form fields need to be inside the same
  form/form tags as your submit button.  The sample HTML you posted
  did not indicate that you'd done this.
 
  Regards,
 
  Paul
  __
 
  Paul Novitski
  Juniper Webcraft Ltd.
  http://juniperwebcraft.com
 
 

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



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Németh Zoltán
On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
 I should not need an actual Button if my link to checkForm() ends with
 document.inputForm.submit(); which tells the form to submit, right?

well, you should be right...
but I remember a year ago or so I had a similar problem and the image
input solved it... but I'm not sure whether it was exactly the same
problem or not, so it might be complete bullshit ;)

greets
Zoltán Németh

 
 On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote: 
 On cs, 2007-02-08 at 08:14 -0500, Dan Shirah wrote:
  Okay, I edited my page per some suggestions here.  Below is
 what I now have: 
 
 
  script language=JavaScript
  function checkForm() {
 
   // ** START **
if (inputForm.cc_phone_number.value == ) {
  alert( Please enter a phone number. ); 
  inputForm.cc_phone_number.focus();
  return;
}
 
  **Lots of other checks here, just left out for
 length**
 
 document.inputForm.submit();
  }
 
  /script
  title/title
  LINK rel=stylesheet type=text/css
 href=../../CSS/background.css
  /head
  body 
  div align=center h2/h2
 h3Submit a New Payment./h3
  /div
  form name=inputForm action=save.php method=post 
  enctype=multipart/form-data
 
  **Lots of form data here**
 
  table align=center border=0 cellpadding=0
 cellspacing=0 
  width=680
   tr
   td width=64 align=lefta
 href=javascript:checkForm()
  title=SaveSave/a/td 
   td width=616 align=lefta
 href=javascript:closeThis()
  title=CloseClose/a/td
   /tr
  /table
  /form 
  /body
  /html
 
  Now when I submit my page it still perfroms all of the
 javascript checks
  correctly, but once it gets to the
 document.inputForm.submit(); part it
  returns the following error. 
 
  Error: Object doesn't support this property or method.
  Code: 0
 
 
 maybe because you don't have submit button in the form?
 try to include something like this
 input type=image src=./images/spacer.gif 
 where spacer.gif is an 1x1 blank image
 
 I remember some similar situation where it helped, but I'm not
 sure
 
 hope that helps
 Zoltán Németh
 
 
 
  On 2/7/07, Paul Novitski [EMAIL PROTECTED] wrote:
  
   At 2/7/2007 01:34 PM, Dan Shirah wrote:
   I have a form that uses Javascript to validate form field
 entries, and if
   they are incorrect it returns an error to the user. 
   
   After the Javascript processing is complete, it submits
 the form to my
   save
   page. However it seems that once the processing is
 complete and it passes
   to 
   the save page, none of my $_POST variables are being
 passed.
  
  
   Of course, all of your form fields need to be inside the
 same
   form/form tags as your submit button.  The sample HTML
 you posted 
   did not indicate that you'd done this.
  
   Regards,
  
   Paul
   __
  
   Paul Novitski
   Juniper Webcraft Ltd. 
   http://juniperwebcraft.com
  
  
 
 

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



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Németh Zoltán
On cs, 2007-02-08 at 08:56 -0500, Dan Shirah wrote:
 Okay, I'll try your spacer solution.   Where do you think I should add
 it?

I put it right before the /form tag, but I think you could put it
anywhere between the form and the /form

greets
Zoltán Németh

 
 On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote: 
 On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
  I should not need an actual Button if my link to checkForm()
 ends with 
  document.inputForm.submit(); which tells the form to submit,
 right?
 
 well, you should be right...
 but I remember a year ago or so I had a similar problem and
 the image
 input solved it... but I'm not sure whether it was exactly the
 same 
 problem or not, so it might be complete bullshit ;)
 
 greets
 Zoltán Németh
 
 
  On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:
  On cs, 2007-02-08 at 08:14 -0500, Dan Shirah wrote: 
   Okay, I edited my page per some suggestions
 here.  Below is
  what I now have:
  
  
   script language=JavaScript 
   function checkForm() {
  
// ** START **
 if (inputForm.cc_phone_number.value == ) {
   alert( Please enter a phone number. ); 
   inputForm.cc_phone_number.focus();
   return;
 }
  
   **Lots of other checks here, just left out for
  length** 
  
  document.inputForm.submit();
   }
  
   /script
   title/title
   LINK rel=stylesheet type=text/css 
  href=../../CSS/background.css
   /head
   body
   div align=center h2/h2
  h3Submit a New Payment./h3 
   /div
   form name=inputForm action=save.php
 method=post
   enctype=multipart/form-data
   
   **Lots of form data here**
  
   table align=center border=0 cellpadding=0
  cellspacing=0 
   width=680
tr
td width=64 align=lefta
  href=javascript:checkForm()
   title=SaveSave/a/td
td width=616 align=lefta
  href=javascript:closeThis()
   title=CloseClose/a/td 
/tr
   /table
   /form
   /body
   /html
  
   Now when I submit my page it still perfroms all of
 the 
  javascript checks
   correctly, but once it gets to the
  document.inputForm.submit(); part it
   returns the following error.
  
   Error: Object doesn't support this property or
 method. 
   Code: 0
  
 
  maybe because you don't have submit button in the
 form?
  try to include something like this
  input type=image src=./images/spacer.gif 
  where spacer.gif is an 1x1 blank image
 
  I remember some similar situation where it helped,
 but I'm not
  sure
 
  hope that helps
  Zoltán Németh 
 
  
  
   On 2/7/07, Paul Novitski
 [EMAIL PROTECTED] wrote:
   
At 2/7/2007 01:34 PM, Dan Shirah wrote: 
I have a form that uses Javascript to validate
 form field
  entries, and if
they are incorrect it returns an error to the
 user.
 
After the Javascript processing is complete, it
 submits
  the form to my
save
page. However it seems that once the processing
 is 
  complete and it passes
to
the save page, none of my $_POST variables are
 being
  passed.
   

Of course, all of your form fields need to be
 inside the
  same
form/form tags as your submit button.  The
 sample HTML
  you posted 
did not indicate that you'd done this.
   
Regards,

Re: [PHP] Javascript and $_POST

2007-02-08 Thread Dan Shirah

Nope, same result unfortunately.

On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:


On cs, 2007-02-08 at 08:56 -0500, Dan Shirah wrote:
 Okay, I'll try your spacer solution.   Where do you think I should add
 it?

I put it right before the /form tag, but I think you could put it
anywhere between the form and the /form

greets
Zoltán Németh


 On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:
 On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
  I should not need an actual Button if my link to checkForm()
 ends with
  document.inputForm.submit(); which tells the form to submit,
 right?

 well, you should be right...
 but I remember a year ago or so I had a similar problem and
 the image
 input solved it... but I'm not sure whether it was exactly the
 same
 problem or not, so it might be complete bullshit ;)

 greets
 Zoltán Németh

 
  On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:
  On cs, 2007-02-08 at 08:14 -0500, Dan Shirah wrote:
   Okay, I edited my page per some suggestions
 here.  Below is
  what I now have:
  
  
   script language=JavaScript
   function checkForm() {
  
// ** START **
 if (inputForm.cc_phone_number.value == ) {
   alert( Please enter a phone number. );
   inputForm.cc_phone_number.focus();
   return;
 }
  
   **Lots of other checks here, just left out for
  length**
  
  document.inputForm.submit();
   }
  
   /script
   title/title
   LINK rel=stylesheet type=text/css
  href=../../CSS/background.css
   /head
   body
   div align=center h2/h2
  h3Submit a New Payment./h3
   /div
   form name=inputForm action=save.php
 method=post
   enctype=multipart/form-data
  
   **Lots of form data here**
  
   table align=center border=0 cellpadding=0
  cellspacing=0
   width=680
tr
td width=64 align=lefta
  href=javascript:checkForm()
   title=SaveSave/a/td
td width=616 align=lefta
  href=javascript:closeThis()
   title=CloseClose/a/td
/tr
   /table
   /form
   /body
   /html
  
   Now when I submit my page it still perfroms all of
 the
  javascript checks
   correctly, but once it gets to the
  document.inputForm.submit(); part it
   returns the following error.
  
   Error: Object doesn't support this property or
 method.
   Code: 0
  
 
  maybe because you don't have submit button in the
 form?
  try to include something like this
  input type=image src=./images/spacer.gif
  where spacer.gif is an 1x1 blank image
 
  I remember some similar situation where it helped,
 but I'm not
  sure
 
  hope that helps
  Zoltán Németh
 
  
  
   On 2/7/07, Paul Novitski
 [EMAIL PROTECTED] wrote:
   
At 2/7/2007 01:34 PM, Dan Shirah wrote:
I have a form that uses Javascript to validate
 form field
  entries, and if
they are incorrect it returns an error to the
 user.

After the Javascript processing is complete, it
 submits
  the form to my
save
page. However it seems that once the processing
 is
  complete and it passes
to
the save page, none of my $_POST variables are
 being
  passed.
   
   
Of course, all of your form fields need to be
 inside the
  same
form/form tags as your submit button.  The
 sample HTML
  you posted
did not indicate that you'd done this.
   

Re: [PHP] Javascript and $_POST

2007-02-08 Thread T . Lensselink
There is nothing wrong with the way you want to submit this form.
Although it's JS :) The sample code you posted was broken in some ways...

missing document. in JS en missing input field to check.

This sample works fine ... 

test.html

script language=JavaScript
function checkForm() {

if (document.inputForm.cc_phone_number.value == ) {
alert( Please enter a phone number. );
document.inputForm.cc_phone_number.focus();
return;
}

document.inputForm.submit();
}

/script
title/title
LINK rel=stylesheet type=text/css href=../../CSS/background.css
/head
body
div align=center 
h2/h2
h3Submit a New Payment./h3
/div

form name=inputForm action=save.php method=post 
enctype=multipart/form-data
input type=text name=cc_phone_number value=8756765756757 /
table align=center border=0 cellpadding=0 cellspacing=0 width=680
tr
td width=64 align=lefta href=javascript:checkForm() 
title=SaveSave/a/td
td width=616 align=lefta href=javascript:closeThis() 
title=CloseClose/a/td
/tr
/table
/form

/body
/html

save.phhp

?php print_r($_POST); ?

Think some other code or JS errors might stop the form from sending data.



On Thu, 8 Feb 2007 09:09:34 -0500, Dan Shirah [EMAIL PROTECTED] wrote:
 Nope, same result unfortunately.
 
 On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:

 On cs, 2007-02-08 at 08:56 -0500, Dan Shirah wrote:
  Okay, I'll try your spacer solution.   Where do you think I should add
  it?

 I put it right before the /form tag, but I think you could put it
 anywhere between the form and the /form

 greets
 Zoltán Németh

 
  On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:
  On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
   I should not need an actual Button if my link to checkForm()
  ends with
   document.inputForm.submit(); which tells the form to submit,
  right?
 
  well, you should be right...
  but I remember a year ago or so I had a similar problem and
  the image
  input solved it... but I'm not sure whether it was exactly the
  same
  problem or not, so it might be complete bullshit ;)
 
  greets
  Zoltán Németh
 
  
   On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:
   On cs, 2007-02-08 at 08:14 -0500, Dan Shirah wrote:
Okay, I edited my page per some suggestions
  here.  Below is
   what I now have:
   
   
script language=JavaScript
function checkForm() {
   
 // ** START **
  if (inputForm.cc_phone_number.value == ) {
alert( Please enter a phone number. );
inputForm.cc_phone_number.focus();
return;
  }
   
**Lots of other checks here, just left out for
   length**
   
   document.inputForm.submit();
}
   
/script
title/title
LINK rel=stylesheet type=text/css
   href=../../CSS/background.css
/head
body
div align=center h2/h2
   h3Submit a New Payment./h3
/div
form name=inputForm action=save.php
  method=post
enctype=multipart/form-data
   
**Lots of form data here**
   
table align=center border=0 cellpadding=0
   cellspacing=0
width=680
 tr
 td width=64 align=lefta
   href=javascript:checkForm()
title=SaveSave/a/td
 td width=616 align=lefta
   href=javascript:closeThis()
title=CloseClose/a/td
 /tr
/table
/form
/body
/html
   
Now when I submit my page it still perfroms all of
  the
   javascript checks
correctly, but once it gets to the
   document.inputForm.submit(); part it
returns the following error.
   
Error: Object doesn't support this property or
  method.
Code: 0
   
  
   maybe because you don't have submit button in the
  form?
   try to include something like this
   input type=image src=./images/spacer.gif
   where spacer.gif is an 1x1 blank image
  
   I remember some similar 

Re: [PHP] Javascript and $_POST

2007-02-08 Thread Németh Zoltán
On cs, 2007-02-08 at 09:09 -0500, Dan Shirah wrote:
 Nope, same result unfortunately.

well, sorry, then my memories were incorrect
maybe I should run a memtest86 on myself ;)

greets
Zoltán Németh

 
 On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote: 
 On cs, 2007-02-08 at 08:56 -0500, Dan Shirah wrote:
  Okay, I'll try your spacer solution.   Where do you think I
 should add 
  it?
 
 I put it right before the /form tag, but I think you could
 put it
 anywhere between the form and the /form
 
 greets
 Zoltán Németh
 
 
  On 2/8/07, Németh Zoltán  [EMAIL PROTECTED] wrote:
  On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
   I should not need an actual Button if my link to
 checkForm() 
  ends with
   document.inputForm.submit(); which tells the form
 to submit,
  right?
 
  well, you should be right...
  but I remember a year ago or so I had a similar
 problem and 
  the image
  input solved it... but I'm not sure whether it was
 exactly the
  same
  problem or not, so it might be complete bullshit ;)
 
  greets 
  Zoltán Németh
 
  
   On 2/8/07, Németh Zoltán [EMAIL PROTECTED]
 wrote:
   On cs, 2007-02-08 at 08:14 -0500, Dan
 Shirah wrote: 
Okay, I edited my page per some
 suggestions
  here.  Below is
   what I now have:
   

script language=JavaScript
function checkForm() {
   
 // ** START ** 
  if (inputForm.cc_phone_number.value ==
 ) {
alert( Please enter a phone
 number. );
inputForm.cc_phone_number.focus ();
return;
  }
   
**Lots of other checks here, just
 left out for
   length** 
   
   document.inputForm.submit();
}
   
/script
title/title
LINK rel=stylesheet type=text/css
   href=../../CSS/background.css 
/head
body
div align=center h2/h2
   h3Submit a New Payment./h3 
/div
form name=inputForm action=save.php
  method=post
enctype=multipart/form-data 
   
**Lots of form data here**
   
table align=center border=0
 cellpadding=0 
   cellspacing=0
width=680
 tr
 td width=64 align=lefta 
   href=javascript:checkForm()
title=SaveSave/a/td
 td width=616 align=lefta 
   href=javascript:closeThis()
title=CloseClose/a/td
 /tr
/table 
/form
/body
/html
   
Now when I submit my page it still
 perfroms all of 
  the
   javascript checks
correctly, but once it gets to the
   document.inputForm.submit(); part it
returns the following error. 
   
Error: Object doesn't support this
 property or
  method.
Code: 0
   
  
   maybe because you don't have submit button
 in the
  form?
   try to include something like this
   input type=image
 src=./images/spacer.gif 
   where spacer.gif is an 1x1 blank image
  
   I remember some similar situation where it
 helped,
  

Re: [PHP] Javascript and $_POST

2007-02-08 Thread Jon Anderson
I'm no JavaScript expert, but I could maybe suggest an alternate method: 
use document.getElementById() or document.getElementsByName()


AFAIK, the direct document.xyz doesn't work exactly the same way accross 
browsers (if at all).


e.g. (WARNING! TOTALLY UNTESTED CODE!)

function checkInputValue(item,onError) {
   if (item = document.getElementsByName(item)[0]) {
  if (item.value != ) {
 return(true);
  }
   }
   alert(onError);
   item.focus();
   return(false);
}

function checkForm() {
   elements = new Array('cc_phone_number');
   errors = new Array('Please enter a phone number');

   for (i=0;ielements.length;i++) {
   if (!checkInputValue(elements[i],errors[i])) {
   return(false);
   }
   }

   document.getElementsByName('inputForm')[0].submit();
}

Dan Shirah wrote:
Okay, I edited my page per some suggestions here.  Below is what I now 
have:



script language=JavaScript
function checkForm() {

// ** START **
 if (inputForm.cc_phone_number.value == ) {
   alert( Please enter a phone number. );
   inputForm.cc_phone_number.focus();
   return;
 }

**Lots of other checks here, just left out for length**

  document.inputForm.submit();
}

/script
title/title
LINK rel=stylesheet type=text/css href=../../CSS/background.css
/head
body
div align=center h2/h2
  h3Submit a New Payment./h3
/div
form name=inputForm action=save.php method=post
enctype=multipart/form-data

**Lots of form data here**

table align=center border=0 cellpadding=0 cellspacing=0
width=680
tr
td width=64 align=lefta href=javascript:checkForm()
title=SaveSave/a/td
td width=616 align=lefta href=javascript:closeThis()
title=CloseClose/a/td
/tr
/table
/form
/body
/html

Now when I submit my page it still perfroms all of the javascript checks
correctly, but once it gets to the document.inputForm.submit(); part it
returns the following error.

Error: Object doesn't support this property or method.
Code: 0



On 2/7/07, Paul Novitski [EMAIL PROTECTED] wrote:


At 2/7/2007 01:34 PM, Dan Shirah wrote:
I have a form that uses Javascript to validate form field entries, 
and if

they are incorrect it returns an error to the user.

After the Javascript processing is complete, it submits the form to my
save
page. However it seems that once the processing is complete and it 
passes

to
the save page, none of my $_POST variables are being passed.


Of course, all of your form fields need to be inside the same
form/form tags as your submit button.  The sample HTML you posted
did not indicate that you'd done this.

Regards,

Paul
__

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com






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



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Dan Shirah

Jon,

Tried your method and still got:
*Error: Object doesn't support this property or method.
Code: 0*



On 2/8/07, Jon Anderson [EMAIL PROTECTED] wrote:


I'm no JavaScript expert, but I could maybe suggest an alternate method:
use document.getElementById() or document.getElementsByName()

AFAIK, the direct document.xyz doesn't work exactly the same way accross
browsers (if at all).

e.g. (WARNING! TOTALLY UNTESTED CODE!)

function checkInputValue(item,onError) {
   if (item = document.getElementsByName(item)[0]) {
  if (item.value != ) {
 return(true);
  }
   }
   alert(onError);
   item.focus();
   return(false);
}

function checkForm() {
   elements = new Array('cc_phone_number');
   errors = new Array('Please enter a phone number');

   for (i=0;ielements.length;i++) {
   if (!checkInputValue(elements[i],errors[i])) {
   return(false);
   }
   }

   document.getElementsByName('inputForm')[0].submit();
}

Dan Shirah wrote:
 Okay, I edited my page per some suggestions here.  Below is what I now
 have:


 script language=JavaScript
 function checkForm() {

 // ** START **
  if (inputForm.cc_phone_number.value == ) {
alert( Please enter a phone number. );
inputForm.cc_phone_number.focus();
return;
  }

 **Lots of other checks here, just left out for length**

   document.inputForm.submit();
 }

 /script
 title/title
 LINK rel=stylesheet type=text/css href=../../CSS/background.css
 /head
 body
 div align=center h2/h2
   h3Submit a New Payment./h3
 /div
 form name=inputForm action=save.php method=post
 enctype=multipart/form-data

 **Lots of form data here**

 table align=center border=0 cellpadding=0 cellspacing=0
 width=680
 tr
 td width=64 align=lefta href=javascript:checkForm()
 title=SaveSave/a/td
 td width=616 align=lefta href=javascript:closeThis()
 title=CloseClose/a/td
 /tr
 /table
 /form
 /body
 /html

 Now when I submit my page it still perfroms all of the javascript checks
 correctly, but once it gets to the document.inputForm.submit(); part it
 returns the following error.

 Error: Object doesn't support this property or method.
 Code: 0



 On 2/7/07, Paul Novitski [EMAIL PROTECTED] wrote:

 At 2/7/2007 01:34 PM, Dan Shirah wrote:
 I have a form that uses Javascript to validate form field entries,
 and if
 they are incorrect it returns an error to the user.
 
 After the Javascript processing is complete, it submits the form to my
 save
 page. However it seems that once the processing is complete and it
 passes
 to
 the save page, none of my $_POST variables are being passed.


 Of course, all of your form fields need to be inside the same
 form/form tags as your submit button.  The sample HTML you posted
 did not indicate that you'd done this.

 Regards,

 Paul
 __

 Paul Novitski
 Juniper Webcraft Ltd.
 http://juniperwebcraft.com







Re: [PHP] Javascript and $_POST

2007-02-08 Thread T . Lensselink
Don't see how this can pass the check without document.

if (inputForm.cc_phone_number.value == ) {
alert( Please enter a phone number. );
inputForm.cc_phone_number.focus();
return;
}

Comming to this check already gives an error.
Maybe ask on some Javascript list.

P.s. reply to the list please. 

On Thu, 8 Feb 2007 09:45:59 -0500, Dan Shirah [EMAIL PROTECTED] wrote:
 Okay, here is ALL of my checkForm() function.
 
 
 function checkForm() {
 
 ***This check passes***
   if (inputForm.cc_phone_number.value == ) {
 alert( Please enter a phone number. );
 inputForm.cc_phone_number.focus();
 return;
   }
 
 
 ***This check passes***
if (inputForm.receipt.value == ) {
 alert( Please select whether or not a receipt was requested. );
 inputForm.receipt.focus();
 return;
   }
 
 
 ***This check passes***
   if (inputForm.case_number.value == ) {
 alert( Please enter a case number. );
 inputForm.case_number.focus();
 return;
   }
 
 
 ***This check passes***
   if (inputForm.cc_first_name.value == ) {
 alert( Please enter a first name. );
 inputForm.cc_first_name.focus();
 return;
   }
 
 
 ***This check passes***
   if (inputForm.cc_last_name.value == ) {
 alert( Please enter a last name. );
 inputForm.cc_last_name.focus();
 return;
   }
 
 
 ***This check passes***
   if (inputForm.cc_middle_name.value == ) {
 alert( Please enter a middle name. );
 inputForm.cc_middle_name.focus();
 return;
   }
 
 
 ***This check passes***
  if (!(document.inputForm.cc_comments.value ==)) {
   if (document.inputForm.cc_comments.value.length  250)
   {
 alert(The Comments must be less than 250 characters.\nIt is currently
 
 + document.inputForm.window_name.value.length +  characters.);
document.inputForm.window_name.focus();
return;
   }
  }
 
 
 
 ***Error: Object doesn't support this property or method.
 Code: 0***
  document.inputForm.submit();
 }
 
 //--
 /script
 
 
 
 On 2/8/07, T. Lensselink [EMAIL PROTECTED] wrote:

 There is nothing wrong with the way you want to submit this form.
 Although it's JS :) The sample code you posted was broken in some
 ways...

 missing document. in JS en missing input field to check.

 This sample works fine ...

 test.html

 script language=JavaScript
 function checkForm() {

 if (document.inputForm.cc_phone_number.value == ) {
alert( Please enter a phone number. );
document.inputForm.cc_phone_number.focus();
return;
 }

 document.inputForm.submit();
 }

 /script
 title/title
 LINK rel=stylesheet type=text/css href=../../CSS/background.css
 /head
 body
 div align=center
 h2/h2
 h3Submit a New Payment./h3
 /div

 form name=inputForm action=save.php method=post
 enctype=multipart/form-data
 input type=text name=cc_phone_number value=8756765756757 /
 table align=center border=0 cellpadding=0 cellspacing=0
 width=680
 tr
td width=64 align=lefta href=javascript:checkForm()
 title=SaveSave/a/td
td width=616 align=lefta href=javascript:closeThis()
 title=CloseClose/a/td
 /tr
 /table
 /form

 /body
 /html

 save.phhp

 ?php print_r($_POST); ?

 Think some other code or JS errors might stop the form from sending
 data.



 On Thu, 8 Feb 2007 09:09:34 -0500, Dan Shirah [EMAIL PROTECTED]
 wrote:
  Nope, same result unfortunately.
 
  On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:
 
  On cs, 2007-02-08 at 08:56 -0500, Dan Shirah wrote:
   Okay, I'll try your spacer solution.   Where do you think I should
 add
   it?
 
  I put it right before the /form tag, but I think you could put it
  anywhere between the form and the /form
 
  greets
  Zoltán Németh
 
  
   On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:
   On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
I should not need an actual Button if my link to
 checkForm()
   ends with
document.inputForm.submit(); which tells the form to
 submit,
   right?
  
   well, you should be right...
   but I remember a year ago or so I had a similar problem and
   the image
   input solved it... but I'm not sure whether it was exactly
 the
   same
   problem or not, so it might be complete bullshit ;)
  
   greets
   Zoltán Németh
  
   
On 2/8/07, Németh Zoltán [EMAIL PROTECTED]
 wrote:
On cs, 2007-02-08 at 08:14 -0500, Dan Shirah
 wrote:
 Okay, I edited my page per some suggestions
   here.  Below is
what I now have:


 script language=JavaScript
 function checkForm() {

  // ** START **
   if (inputForm.cc_phone_number.value == ) {
 alert( Please enter a phone number. );
 inputForm.cc_phone_number.focus();
 return;
   

Re: [PHP] Javascript and $_POST

2007-02-08 Thread Jon Anderson

Dan Shirah wrote:

Jon,
 
Tried your method and still got:

*Error: Object doesn't support this property or method.
Code: 0*
*I don't know what browser/platform you're using, but the following 
works for me on IE7/Windows, FF2/Linux, Opera9/Linux.


jon

html
head
script language=JavaScript
function checkInputValue(item,onError) {
  if (item = document.getElementsByName(item)[0]) {
 if (item.value != ) {
return(true);
 }
 item.focus();
  }
**   alert(onError);
  **return(false);*
*}

function checkForm() {
  elements = new Array('cc_phone_number');
  errors = new Array('Please enter a phone number');

  for (i=0;ielements.length;i++) {
  if (!checkInputValue(elements[i],errors[i])) {
  return(false);
  }
  }

  document.getElementsByName('inputForm')[0].submit();
}
/script
/head
body
form name=inputForm method=post enctype=multipart/form-data
table align=center border=0 cellpadding=0 cellspacing=0 
width=680

tr
tdinput type=text name=cc_phone_number /
/tr
tr
td width=64 align=lefta href=# 
onclick=javascript:checkForm();return(false); title=SaveSave/a/td

/tr
/table
/form
/body
/html

*

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



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Jon Anderson

Jon Anderson wrote:

...
 item.focus();
  }
**   alert(onError);
  **return(false);*
*}
...
Sorry about the *s everywhere (there aren't supposed to be any). I 
pasted the code in, and Thunderbird thought it was supposed to be bold 
for some reason, then converted the bold text to text with *s 
everywhere while sending as plain-text only.


jon

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



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Dan Shirah

You guys are going to kill me!  I found my problemand it's one of those
What the hell were you thinking issues.

Within my form was a button but I stupidly made it a submit when I created
it and therefore the javascript check for submit was finding my button first
and dumping the error.

So, in summary:
function checkForm( )
 {
  document.FormName.submit();
 }
*DOES *work and will pass your $_POST values between pages as long as you
don't make a novice mistake like I did.


On 2/8/07, Jon Anderson [EMAIL PROTECTED] wrote:


Jon Anderson wrote:
 ...
  item.focus();
   }
 **   alert(onError);
   **return(false);*
 *}
 ...
Sorry about the *s everywhere (there aren't supposed to be any). I
pasted the code in, and Thunderbird thought it was supposed to be bold
for some reason, then converted the bold text to text with *s
everywhere while sending as plain-text only.

jon



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Robert Cummings
On Thu, 2007-02-08 at 10:21 -0500, Dan Shirah wrote:
 You guys are going to kill me!  I found my problemand it's one of those
 What the hell were you thinking issues.

Nah, probably lots of us have been bitten by that. I know I have been in
the past, so now I always name my submit buttons continue :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Javascript and $_POST

2007-02-07 Thread Dan Shirah

I have a form that uses Javascript to validate form field entries, and if
they are incorrect it returns an error to the user.

After the Javascript processing is complete, it submits the form to my save
page. However it seems that once the processing is complete and it passes to
the save page, none of my $_POST variables are being passed.

Is this normal, or is there a work around for it?

My Javascript has multiple checks. Below is a very condensed version:

script language=JavaScript
function checkForm() {

if (inputForm.cc_phone_number.value == ) {
alert( Please enter a phone number. );
inputForm.cc_phone_number.focus();
return;
}

document.Submit.submit();
}
/script

And this is my Save option at the bottom of my page

form name=Submit action=save.php method=post
enctype=multipart/form-data
table align=center border=0 cellpadding=0 cellspacing=0
width=680
tr
td width=64 align=lefta href=javascript:checkForm()
title=SaveSave/a/td
/tr
/table
/form

When I click on save, it does go thru all the checks correctly and prompts
to enter info if anything is left out. It then passes me to the
save.phppage as it should, but all of my $_POST('X') values come
in blank.


RE: [PHP] Javascript and $_POST

2007-02-07 Thread Brad Fuller
 -Original Message-
 From: Dan Shirah [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, February 07, 2007 4:35 PM
 To: php-general
 Subject: [PHP] Javascript and $_POST
 
 I have a form that uses Javascript to validate form field entries, and if
 they are incorrect it returns an error to the user.
 
 After the Javascript processing is complete, it submits the form to my
 save
 page. However it seems that once the processing is complete and it passes
 to
 the save page, none of my $_POST variables are being passed.
 
 Is this normal, or is there a work around for it?
 
 My Javascript has multiple checks. Below is a very condensed version:
 
 script language=JavaScript
 function checkForm() {
 
 if (inputForm.cc_phone_number.value == ) {
 alert( Please enter a phone number. );
 inputForm.cc_phone_number.focus();
 return;
 }
 
 document.Submit.submit();
 }
 /script
 
 And this is my Save option at the bottom of my page
 
 form name=Submit action=save.php method=post
 enctype=multipart/form-data
 table align=center border=0 cellpadding=0 cellspacing=0
 width=680
 tr
 td width=64 align=lefta href=javascript:checkForm()
 title=SaveSave/a/td
 /tr
 /table
 /form
 
 When I click on save, it does go thru all the checks correctly and prompts
 to enter info if anything is left out. It then passes me to the
 save.phppage as it should, but all of my $_POST('X') values come
 in blank.


From the looks of it, you have two forms - one called Submit and one
called inputForm.  You need to submit the inputForm for the values to be
passed to the processing page.

document.inputForm.submit();

HTH,

Brad



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



Re: [PHP] Javascript and $_POST

2007-02-07 Thread Jon Anderson

Dan Shirah wrote:

And this is my Save option at the bottom of my page

form name=Submit action=save.php method=post
enctype=multipart/form-data
table align=center border=0 cellpadding=0 cellspacing=0
width=680
tr
td width=64 align=lefta href=javascript:checkForm()
title=SaveSave/a/td
/tr
/table
/form 
ErWhy aren't there any input elements within the form tag? Maybe 
you just condensed-out the inputs, but if your inputs aren't within the 
form, they won't be submitted.


E.g. if you have:

form id=dataForm
input ... /
input ... /
/form

form id=submitForm
...
/form

If you submit submitForm, nothing will get posted. You want to post 
dataForm in the above example. (Or whatever inputForm happens to be 
in your example.)


jon

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



  1   2   3   4   5   6   >