Re: [PHP] $POST Q

2006-12-18 Thread Nisse Engström
On Fri, 15 Dec 2006 23:22:13 -0600 (CST), Richard Lynch wrote:

 $selected = $l == $limit ? 'selected=selected' : '';
 echo option value=\$l\ $selected$l/option\n;

[snip]

 The value=x *is* optional, but you'll never convince the people who
 tell you it isn't, unless you force them to read the RFCs and W3C
 recommendations [*], so it's easier to include it than to argue with
 them. :-)

   It is indeed optional, and the HTML spec.[1] even says
that if the attribute is not set, the initial value is
set to the contents of the element. That's all good and
well.

   What's not all good and well are browser implementations.
If you try to retrieve the value from JavaScript (by way
of option.value or select.value) in IE 5.5 [2] and several
versions of Opera [3], you may find the value is simply
not there *unless* you spell it out in HTML.

   Of course, it could be argued that there is a conceptual
difference between the value attribute (as written in HTML
and seen through the JS DOM) and the element value (rendered
by the user agent and passed as part of a form submission).
But that is a different story for a different group (or list).
I fear that I have now strayed so far off topic that I should
volunteer myself for killfile membership. :-)


--nfe


[1]: I'm not going to bother checking the XHTML spec.
[2]: I don't know about other versions.
[3]: The bug dates back to at least Opera 7.23. I reported
 it in july 2004 against 7.52, as did others before me.
 It was finally fixed in 9.00 preview 1, some two years
 after I reported it.

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



Re: [PHP] $POST Q

2006-12-18 Thread Richard Lynch
On Mon, December 18, 2006 7:09 am, Nisse Engström wrote:
 On Fri, 15 Dec 2006 23:22:13 -0600 (CST), Richard Lynch wrote:

 $selected = $l == $limit ? 'selected=selected' : '';
 echo option value=\$l\ $selected$l/option\n;

 [snip]

 The value=x *is* optional, but you'll never convince the people
 who
 tell you it isn't, unless you force them to read the RFCs and W3C
 recommendations [*], so it's easier to include it than to argue with
 them. :-)

It is indeed optional, and the HTML spec.[1] even says
 that if the attribute is not set, the initial value is
 set to the contents of the element. That's all good and
 well.

What's not all good and well are browser implementations.
 If you try to retrieve the value from JavaScript (by way
 of option.value or select.value) in IE 5.5 [2] and several
 versions of Opera [3], you may find the value is simply
 not there *unless* you spell it out in HTML.

Ah.

Yeah, now that I actually occasionally use JavaScript, I should
actually pay attention to the gotchas of JS.
:-)

Thanks!

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



Re: [PHP] $POST Q

2006-12-18 Thread Jochem Maas
Richard Lynch wrote:
 On Mon, December 18, 2006 7:09 am, Nisse Engström wrote:
 On Fri, 15 Dec 2006 23:22:13 -0600 (CST), Richard Lynch wrote:

 $selected = $l == $limit ? 'selected=selected' : '';
 echo option value=\$l\ $selected$l/option\n;
 [snip]

 The value=x *is* optional, but you'll never convince the people
 who
 tell you it isn't, unless you force them to read the RFCs and W3C
 recommendations [*], so it's easier to include it than to argue with
 them. :-)
It is indeed optional, and the HTML spec.[1] even says
 that if the attribute is not set, the initial value is
 set to the contents of the element. That's all good and
 well.

What's not all good and well are browser implementations.
 If you try to retrieve the value from JavaScript (by way
 of option.value or select.value) in IE 5.5 [2] and several
 versions of Opera [3], you may find the value is simply
 not there *unless* you spell it out in HTML.
 
 Ah.
 
 Yeah, now that I actually occasionally use JavaScript, I should

^^--- LOOK EVERYONE - we have it in writing at 
last ;-)

 actually pay attention to the gotchas of JS.

I tend to classify them as 'wtf's and 'omg's but that's just the cynic in me :-)

 :-)
 
 Thanks!
 

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



Re: [PHP] $POST Q

2006-12-15 Thread Richard Lynch
On Tue, December 12, 2006 2:14 am, William Stokes wrote:
 Can someone tell me what wrong or to how to manage this?

 //default
 $limitorig = 10;

 echo select name=\USRlimitorig\;
 echo option selected value=$limitorig/option;
 echo option10/option;
 echo option20/option;
 echo option30/option;
 echo input type=\submit\ name=\resetlimit\ value=\GO\;

?php
  $limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : 10;
  $limit = (int) $limit; //crude filtering of input, but effective
?
select name=USERlimitorig
?php
  for ($l = 10; $l = 30; $l += 10){
$selected = $l == $limit ? 'selected=selected' : '';
echo option value=\$l\ $selected$l/option\n;
  }
?
/select
input type=submit name=resetlimit value=GO /

The value=x *is* optional, but you'll never convince the people who
tell you it isn't, unless you force them to read the RFCs and W3C
recommendations [*], so it's easier to include it than to argue with
them. :-)

YMMV
NAIAA

* W3C may have changed their minds on this since last week when we
visited their site after this same topic came up in this very forum...
But I doubt it.

-- 
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] $POST Q

2006-12-12 Thread William Stokes
Hello,

Can someone tell me what wrong or to how to manage this?

//default
$limitorig = 10;

echo select name=\USRlimitorig\;
echo option selected value=$limitorig/option;
echo option10/option;
echo option20/option;
echo option30/option;
echo input type=\submit\ name=\resetlimit\ value=\GO\;

When the form is first printed the selected default (10) value is shown OK 
and if something is selected everything is fine. If I just hit GO without 
changing the select menu the form fails because USRlimitorig will be empty. 
So how to post the $limitorig if user doesn't change it but hits GO 
anyway?

Thanks
-Will

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



Re: [PHP] $POST Q

2006-12-12 Thread clive

William Stokes wrote:

Hello,

Can someone tell me what wrong or to how to manage this?

//default
$limitorig = 10;

echo select name=\USRlimitorig\;
echo option selected value=$limitorig/option;
echo option10/option;
echo option20/option;
echo option30/option;
echo input type=\submit\ name=\resetlimit\ value=\GO\;


firstly its better to use option value='10' 10 /option

this might also solve your problem if I understand your question correctly.



When the form is first printed the selected default (10) value is shown OK 
and if something is selected everything is fine. If I just hit GO without 
changing the select menu the form fails because USRlimitorig will be empty. 
So how to post the $limitorig if user doesn't change it but hits GO 
anyway?


Thanks
-Will



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



Re: [PHP] $POST Q

2006-12-12 Thread Jochem Maas
William Stokes wrote:
 Hello,
 
 Can someone tell me what wrong or to how to manage this?
 
 //default
 $limitorig = 10;
 
 echo select name=\USRlimitorig\;
 echo option selected value=$limitorig/option;

  ^^ what do you think $_POST['USRlimitorig'] will 
be if you select the first option?

 echo option10/option;
 echo option20/option;
 echo option30/option;
 echo input type=\submit\ name=\resetlimit\ value=\GO\;
 
 When the form is first printed the selected default (10) value is shown OK 
 and if something is selected everything is fine. If I just hit GO without 
 changing the select menu the form fails because USRlimitorig will be empty. 
 So how to post the $limitorig if user doesn't change it but hits GO 
 anyway?
 
 Thanks
 -Will
 

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



Re: [PHP] $POST Q

2006-12-12 Thread Chris

William Stokes wrote:

Hello,

Can someone tell me what wrong or to how to manage this?

//default
$limitorig = 10;

echo select name=\USRlimitorig\;
echo option selected value=$limitorig/option;
echo option10/option;
echo option20/option;
echo option30/option;
echo input type=\submit\ name=\resetlimit\ value=\GO\;


Something like this would be better:

$limitorig = 10;
$options = array('10', '20', '30');

if (isset($_POST['limitorig'])  in_array($_POST['limitorig'], $options)) {
  $limitorig = $_POST['limitorig'];
}

foreach ($options as $option) {
  $selected = '';
  if ($option == $limitorig) {
$selected = ' SELECTED';
  }
  echo 'option value=' . $option . ' ' . $selected . '' . $option . 
'/option';

}


might be a bit long winded but you can easily add more to the array, the 
in_array check makes sure nobody tries to hack the script by entering 
dummy values (or by creating their own script to submit the form) and it 
should also stop xss attacks.


--
Postgresql  php tutorials
http://www.designmagick.com/

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