Re: passing values into javascript [message #179876 is a reply to message #179873] |
Sat, 15 December 2012 21:36 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Sat, 15 Dec 2012 13:10:42 +0000, Denis McMahon wrote:
> $myval1 = 50; // default value if ( isset( $_GET['myval1'] ) &&
> preg_match( '/^[2-7][0-9]$/', $_GET ['myval1'] ) == 1 ) {
> $myval1 = intval( $_GET['myval1'] );
> if ( $myval1 < 25 ) $myval1 = 25; // lower limit value if ( $myval1 > 75
> )
> $myval1 = 75; // upper limit value }
Typical ballsed up wrapping ...
$myval1 = 50; // default value
// check if a get value was received and that it has the expected
// text format
if ( isset( $_GET['myval1'] ) && preg_match( '/^[2-7][0-9]$/', $_GET
['myval1'] ) == 1 ) {
$myval1 = intval( $_GET[ 'myval1' ] ); // get the int value
if ( $myval1 < 25 ) $myval1 = 25; // lower limit value
if ( $myval1 > 75 ) $myval1 = 75; // upper limit value
}
Rgds
Denis McMahon
|
|
|