Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #10408 > unrolled thread
| Started by | cerr <ron.eggler@gmail.com> |
|---|---|
| First post | 2012-01-19 14:17 -0800 |
| Last post | 2012-01-21 22:17 +0100 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.javascript
read get variables and show/hide div cerr <ron.eggler@gmail.com> - 2012-01-19 14:17 -0800
Re: read get variables and show/hide div Jeff North <jnorthau@yahoo.com.au> - 2012-01-20 09:57 +1100
Re: read get variables and show/hide div cerr <ron.eggler@gmail.com> - 2012-01-19 15:32 -0800
Re: read get variables and show/hide div Jeff North <jnorthau@yahoo.com.au> - 2012-01-20 18:13 +1100
Re: read get variables and show/hide div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-21 22:17 +0100
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-01-19 14:17 -0800 |
| Subject | read get variables and show/hide div |
| Message-ID | <33182896-a3fa-463b-8bd0-bb14a17e962b@4g2000pbz.googlegroups.com> |
Hi, I want to display a div but only if no GET variable "email" is present. And I would like to hide my div when someone hits a specific button. So far I have come up with this: http://pizzalita.com/index1.html?email=MyEmail There's that div in the middle (shat should not show because there's email in GET) and when someone clicks the cross, it should disappear.... but I don't get it working correctly. Some help would be gladly appreciated! Thank you very much!!! Ron
[toc] | [next] | [standalone]
| From | Jeff North <jnorthau@yahoo.com.au> |
|---|---|
| Date | 2012-01-20 09:57 +1100 |
| Message-ID | <t77hh7lcrk9c38ajbt7f295fi0vc99ftv3@4ax.com> |
| In reply to | #10408 |
On Thu, 19 Jan 2012 14:17:44 -0800 (PST), in comp.lang.javascript cerr <ron.eggler@gmail.com> <33182896-a3fa-463b-8bd0-bb14a17e962b@4g2000pbz.googlegroups.com> wrote: >| Hi, >| >| I want to display a div but only if no GET variable "email" is >| present. >| And I would like to hide my div when someone hits a specific button. >| So far I have come up with this: >| http://pizzalita.com/index1.html?email=MyEmail >| >| There's that div in the middle (shat should not show because there's >| email in GET) and when someone clicks the cross, it should >| disappear.... but I don't get it working correctly. >| Some help would be gladly appreciated! >| Thank you very much!!! >| >| Ron If you get rid of the error on the page you might find out why it isn't working i.e line 290 http://validator.w3.org/check?uri=http%3A%2F%2Fpizzalita.com%2Findex1.html&charset=%28detect+automatically%29&doctype=Inline&group=0
[toc] | [prev] | [next] | [standalone]
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-01-19 15:32 -0800 |
| Message-ID | <423fce4d-72bc-442d-bd22-8d5b90459545@iu7g2000pbc.googlegroups.com> |
| In reply to | #10409 |
On Jan 19, 2:57 pm, Jeff North <jnort...@yahoo.com.au> wrote: > On Thu, 19 Jan 2012 14:17:44 -0800 (PST), in comp.lang.javascript cerr > <ron.egg...@gmail.com> > <33182896-a3fa-463b-8bd0-bb14a17e9...@4g2000pbz.googlegroups.com> > wrote: > > >| Hi, > >| > >| I want to display a div but only if no GET variable "email" is > >| present. > >| And I would like to hide my div when someone hits a specific button. > >| So far I have come up with this: > >|http://pizzalita.com/index1.html?email=MyEmail > >| > >| There's that div in the middle (shat should not show because there's > >| email in GET) and when someone clicks the cross, it should > >| disappear.... but I don't get it working correctly. > >| Some help would be gladly appreciated! > >| Thank you very much!!! > >| > >| Ron > > If you get rid of the error on the page you might find out why it > isn't working i.e line 290 > > http://validator.w3.org/check?uri=http%3A%2F%2Fpizzalita.com%2Findex1... Yep, thank you, got it partly going (had to use GetElemenById instead of GetElementsByName) but I'm still not able to retrieve the GET variable. I got the Regular expression and the $_GET() function from http://www.onlineaspect.com/2009/06/10/reading-get-variables-with-javascript/ Can you - or anyone else for that matter - see what is wrong? Thank you! Again, the URL: http://pizzalita.com/index1.html?email=jkhkljh
[toc] | [prev] | [next] | [standalone]
| From | Jeff North <jnorthau@yahoo.com.au> |
|---|---|
| Date | 2012-01-20 18:13 +1100 |
| Message-ID | <ba2ih7lkpg7ee01e5dtu79puq9o2hfscom@4ax.com> |
| In reply to | #10410 |
On Thu, 19 Jan 2012 15:32:59 -0800 (PST), in comp.lang.javascript cerr
<ron.eggler@gmail.com>
<423fce4d-72bc-442d-bd22-8d5b90459545@iu7g2000pbc.googlegroups.com>
wrote:
>| On Jan 19, 2:57 pm, Jeff North <jnort...@yahoo.com.au> wrote:
>| > On Thu, 19 Jan 2012 14:17:44 -0800 (PST), in comp.lang.javascript cerr
>| > <ron.egg...@gmail.com>
>| > <33182896-a3fa-463b-8bd0-bb14a17e9...@4g2000pbz.googlegroups.com>
>| > wrote:
>| >
>| > >| Hi,
>| > >|
>| > >| I want to display a div but only if no GET variable "email" is
>| > >| present.
>| > >| And I would like to hide my div when someone hits a specific button.
>| > >| So far I have come up with this:
>| > >|http://pizzalita.com/index1.html?email=MyEmail
>| > >|
>| > >| There's that div in the middle (shat should not show because there's
>| > >| email in GET) and when someone clicks the cross, it should
>| > >| disappear.... but I don't get it working correctly.
>| > >| Some help would be gladly appreciated!
>| > >| Thank you very much!!!
>| > >|
>| > >| Ron
>| >
>| > If you get rid of the error on the page you might find out why it
>| > isn't working i.e line 290
>| >
>| > http://validator.w3.org/check?uri=http%3A%2F%2Fpizzalita.com%2Findex1...
>|
>| Yep, thank you, got it partly going (had to use GetElemenById instead
>| of GetElementsByName) but I'm still not able to retrieve the GET
>| variable.
>| I got the Regular expression and the $_GET() function from
>| http://www.onlineaspect.com/2009/06/10/reading-get-variables-with-javascript/
>| Can you - or anyone else for that matter - see what is wrong?
The $_GET function is throwing an error which in turn prevents all the
other scripts from running. Try replacing the current $_GET function
with
function $_GET(q,s) {
var res = new Array();
s = (s != null) ? s : window.location.search;
var re = new RegExp("("+q+"[ |=])(.*?)(?=&|$)","i");
var result = s.match(re);
return (result == null ) ? '' : result[2];
}
Another problem is that you are not calling the $_GET function so
there is no-way that it is going to be executed. You need to add:
if( $_GET('email') != '' ) closediv();
just after the $_GET function.
>| Thank you!
>| Again, the URL:
>| http://pizzalita.com/index1.html?email=jkhkljh
The previous RegExp and this RegExp does *not* check if the email
address is well-formed. Thus the above example would hide the emaildiv
'window'.
If you want to check that there is a well-formed email address then
replace the $_GET function with the following (delete the line 'if(
$_GET('email') != '' ) closediv();' also:
function $_GET(q,s) {
var res = new Array();
s = (s != null) ? s : window.location.search;
var re = new RegExp("("+q+"[ |=])(.*?)(?=&|$)","i");
var result = s.match(re);
return (result == null ) ? '' : result[2];
}
function checkEmail(email) {
var re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i;
var x = email.match(re);
return( x == null ) ? false : true;
}
if( checkEmail( $_GET('email') ) == true ) closediv();
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-01-21 22:17 +0100 |
| Message-ID | <1917513.ZmKo30s5rG@PointedEars.de> |
| In reply to | #10416 |
Jeff North wrote:
> The $_GET function is throwing an error which in turn prevents all the
> other scripts from running. Try replacing the current $_GET function
> with
> function $_GET(q,s) {
> var res = new Array();
> s = (s != null) ? s : window.location.search;
> var re = new RegExp("("+q+"[ |=])(.*?)(?=&|$)","i");
> var result = s.match(re);
> return (result == null ) ? '' : result[2];
> }
>
> Another problem is that you are not calling the $_GET function so
> there is no-way that it is going to be executed. You need to add:
> if( $_GET('email') != '' ) closediv();
> just after the $_GET function.
Potentially confusing and harder-to-maintain results of such identifier
abuse were probably one reason why ECMAScript Edition 3 contained a note
that identifiers starting with `$' should be machine-generated.
Please do not do that.
PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web