Solved

My website popupwindow dosent work now ?

Posted on 2011-02-19
46
950 Views
Last Modified: 2012-05-11
Hi!

Have this code to popup a window, to ask
user to enter a postnr...

<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(){
            $husk_postnr2=prompt("Legg inn postnummer","Postnummer");
            if ($husk_postnr2!=""){
                  /*insert the store script, use what you want*/
                  window.location=href+"&postnr="+husk_postnr2;

            }
        return false;
    }
//]]>
</script>

<h2>Hvem er dere?</h2>
<a href="http://dugnaden.no/tjen-penger/?preset=klasse&;[husk_postnr2]"></a>
<div class="knapp" style="float: left;">
<h4><a href="http://dugnaden.no/tjen-penger/?preset=klasse&;[husk_postnr2]" onclick="return showPrompt(this.title);"><img title="klasse" src="http://dugnaden.no/wp-content/uploads/2009/10/klasse.png" alt="klasse" width="90" height="50" />
Skoleklasse</a></h4></div>

But the window dosent show up ???

What is wrong ?
0
Comment
Question by:team2005
  • 28
  • 18
46 Comments
 
LVL 4

Expert Comment

by:andreizz
ID: 34933807
<html>
<head>
   <script type="text/javascript">
   //<![CDATA[
    function showPrompt(href){
		husk_postnr2=prompt("Legg inn postnummer","");
		if (husk_postnr2!=null && husk_postnr2!=""){
			window.location=href+"&husk_postnr2="+husk_postnr2;
		}
    }
	//]]>
</script>
</head>
<body>
	<div class="knapp" style="float: left;">
		<h4>
			<div style="cursor: pointer" title="http://dugnaden.no/tjen-penger/?preset=russ" onclick="showPrompt(this.title)">
				<img title="russ"  src="http://dugnaden.no/wp-content/uploads/2009/10/russ.png" alt="russ" width="90" height="50" />
			</div>
		</h4>
	</div>
</body>
</html>

Open in new window


i gave you this solution that is good, what is the problem?
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34933812
btw i copied your script:
<html>
<head><script type="text/javascript">
//<![CDATA[
    var showPrompt = function(){
            $husk_postnr2=prompt("Legg inn postnummer");
            if ($husk_postnr2!=""){
                  /*insert the store script, use what you want*/
                  window.location=href+"&postnr="+husk_postnr2;

            }
        return false;
    }
//]]>
</script>
</head>
<body>
<h2>Hvem er dere?</h2>
<a href="http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]"></a>
<div class="knapp" style="float: left;">
<h4><a href="http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]" onclick="return showPrompt(this.title);"><img title="klasse" src="http://dugnaden.no/wp-content/uploads/2009/10/klasse.png" alt="klasse" width="90" height="50" />
Skoleklasse</a></h4></div>
</body>
</html>

Open in new window


and the prompt window is displayed..
0
 
LVL 2

Author Comment

by:team2005
ID: 34933909
Whys dosent it work on my computer ?

I am using Firefox

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34933920
I am also using firefox, maybe you have javascript disabled, go to tools->options->content->enable java script
and also try the script in ie or another browser.
0
 
LVL 2

Author Comment

by:team2005
ID: 34933974
Javascript is enabled in firefox..

If you enter example: 3100
Do you see postnr=3100 in the url ?

Olso tryed this in IE, but there it say that its a error on the page ?

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34933991
with the code that you posted nothing is sent to the url because you put the onclick event on a <a> tag and it follows the link from href first instead of the window.location from js.

0
 
LVL 2

Author Comment

by:team2005
ID: 34934109
Hi!

How do i send this to url then ?
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934138
window.location=href+"&husk_postnr2="+husk_postnr2;

Open in new window

with this line, but you have this already added you only have to remove the <a> tag and replace it with:

<div style="cursor: pointer" title="http://dugnaden.no/tjen-penger/?preset=russ" onclick="showPrompt(this.title)">
				<img title="russ"  src="http://dugnaden.no/wp-content/uploads/2009/10/russ.png" alt="russ" width="90" height="50" />
			</div>

Open in new window

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934146
post the code you have so far, including the <html></html> tags and i will modify it for you.
0
 
LVL 2

Author Comment

by:team2005
ID: 34934166
Hi!

This is the code i have now:


<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     $husk_postnr2=prompt("Legg inn postnummer");
            if ($husk_postnr2!=""){
                  /*insert the store script, use what you want*/
                 window.location=href+"&postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>
<span style="font-size: 1.4em; line-height: 1.5em;">Vi selger sekker med toalettpapir og tørkeruller som dere kan selge videre gjennom dugnad med god fortjeneste!</span>
[husk_postnr2];
MINSTE-BESTILLING 40 SEKKER
<h2>Hvem er dere?</h2>
<a href="http://dugnaden.no/tjen-penger/?preset=klasse&amp;;[husk_postnr2]"></a>
<div class="knapp" style="float: left;">
<h4><a href="http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]" onclick="return showPrompt("http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]");"><img title="klasse" src="http://dugnaden.no/wp-content/uploads/2009/10/klasse.png" alt="klasse" width="90" height="50" />
Skoleklasse</a></h4></div>
<a href="http://dugnaden.no/tjen-penger/?preset=russ&amp;[husk_postnr2]"></a>
<div class="knapp" style="float: left;">
<h4><a href="http://dugnaden.no/tjen-penger/?preset=russ&amp;[husk_postnr2]" onclick="return showPrompt(this.title);"><img title="russ" src="http://dugnaden.no/wp-content/uploads/2009/10/russ.png" alt="russ" width="90" height="50" />
Russ</a></h4></div>
<a href="http://dugnaden.no/tjen-penger/?preset=idrettslag&amp;[husk_postnr2]"></a>
<div class="knapp" style="float: left;">
<h4><a href="http://dugnaden.no/tjen-penger/?preset=idrettslag&amp;[husk_postnr2]" onclick="return showPrompt(this.title);"><img title="idrettslag" src="http://dugnaden.no/wp-content/uploads/2009/10/idrettslag.png" alt="idrettslag" width="90" height="50" />
Idrettslag</a></h4>
</div>
<a href="http://dugnaden.no/tjen-penger/?preset=korpsogkor&amp;[husk_postnr2]"></a>
<div class="knapp" style="float: left;">
<h4><a href="http://dugnaden.no/tjen-penger/?preset=korpsogkor&amp;[husk_postnr2]" onclick="return showPrompt(this.title);"><img title="korpsogkor" src="http://dugnaden.no/wp-content/uploads/2009/10/korpsogkor.png" alt="korpsogkor" width="90" height="50" />
Korps/kor</a></h4>
</div>
<a href="http://dugnaden.no/tjen-penger/?preset=annen&amp;[husk_postnr2]"></a>
<div class="knapp" style="float: left; padding-top: 0px;">
<h4><a href="http://dugnaden.no/tjen-penger/?preset=annen&amp;[husk_postnr2]" onclick="return showPrompt(this.title);"><img title="annen" src="http://dugnaden.no/wp-content/uploads/2009/10/annen.png" alt="annen" width="90" height="50" />
Annen forening</a></h4>
</div>
<a href="http://dugnaden.no/produkter/"><img class="size-full wp-image-495" title="Våre produkter" src="http://dugnaden.no/wp-content/uploads/2009/10/produkter2.jpg" alt="Tørkeruller og toalettpapir" width="650" height="390" /></a>

Open in new window

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934239
<html>
<head>
<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""){
                 window.location=href+"&postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>
</head>
<body>
<span style="font-size: 1.4em; line-height: 1.5em;">Vi selger sekker med toalettpapir og tørkeruller som dere kan selge videre gjennom dugnad med god fortjeneste!</span>
[husk_postnr2];
MINSTE-BESTILLING 40 SEKKER
<h2>Hvem er dere?</h2>
<a href="http://dugnaden.no/tjen-penger/?preset=klasse&amp;;[husk_postnr2]"></a>
<div class="knapp" style="float: left;">
<div style="cursor: pointer; display: inline-table;" onclick="showPrompt('http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]')">
<img title="klasse" src="http://dugnaden.no/wp-content/uploads/2009/10/klasse.png" alt="klasse" width="90" height="50" />
<h4>Skoleklasse</h4></div>
<div style="cursor: pointer; display: inline-table;" onclick="showPrompt('http://dugnaden.no/tjen-penger/?preset=russ&amp;[husk_postnr2]')">
<img title="russ" src="http://dugnaden.no/wp-content/uploads/2009/10/russ.png" alt="russ" width="90" height="50" />
<h4>Russ</h4></div>
<div style="cursor: pointer; display: inline-table;" onclick="showPrompt('http://dugnaden.no/tjen-penger/?preset=idrettslag&amp;[husk_postnr2]')">
<img title="idrettslag" src="http://dugnaden.no/wp-content/uploads/2009/10/idrettslag.png" alt="idrettslag" width="90" height="50" />
<h4>Idrettslag</h4></div>
<div style="cursor: pointer; display: inline-table;" onclick="showPrompt('http://dugnaden.no/tjen-penger/?preset=korpsogkor&amp;[husk_postnr2]')">
<img title="korpsogkor" src="http://dugnaden.no/wp-content/uploads/2009/10/korpsogkor.png" alt="korpsogkor" width="90" height="50" />
<h4>Korps/kor</h4></div>
<div style="cursor: pointer; display: inline-table;" onclick="showPrompt('http://dugnaden.no/tjen-penger/?preset=annen&amp;[husk_postnr2]')">
<img title="annen" src="http://dugnaden.no/wp-content/uploads/2009/10/annen.png" alt="annen" width="90" height="50" />
<h4>Annen forening</h4></div>
<br/>
<a href="http://dugnaden.no/produkter/"><img class="size-full wp-image-495" title="Våre produkter" src="http://dugnaden.no/wp-content/uploads/2009/10/produkter2.jpg" alt="Tørkeruller og toalettpapir" width="650" height="390" /></a>
</body>
</html>

Open in new window

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934245
your first mistake was that you put a $ sign in front of the js variables
$husk_postnr2
and that made then not pass the validation test.

Be more carefull, js doesn't have $ in front of variables.
0
 
LVL 2

Author Comment

by:team2005
ID: 34934485
Hi!

Your code dosent work, its show the pictures
in 5 rows... Not on 1 line ?

And http://.... after enter number is:
http://dugnaden.no/tjen-penger/?preset=klasse#038;postnr=3100



0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934538
<html>
<head>
<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""&&husk_postnr2!=null){
                  /*insert the store script, use what you want*/
                 window.location=href+"&postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>
</head>
<body>
<span style="font-size: 1.4em; line-height: 1.5em;">Vi selger sekker med toalettpapir og tørkeruller som dere kan selge videre gjennom dugnad med god fortjeneste!</span>
[husk_postnr2];
MINSTE-BESTILLING 40 SEKKER
<h2>Hvem er dere?</h2>

<div class="knapp" style="float: left;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]');">
<h4><img title="klasse" src="http://dugnaden.no/wp-content/uploads/2009/10/klasse.png" alt="klasse" width="90" height="50" />
Skoleklasse</h4></div>

<div class="knapp" style="float: left;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=russ&amp;[husk_postnr2]');">
<h4><img title="russ" src="http://dugnaden.no/wp-content/uploads/2009/10/russ.png" alt="russ" width="90" height="50" />
Russ</h4></div>

<div class="knapp" style="float: left;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=idrettslag&amp;[husk_postnr2]');">
<h4><img title="idrettslag" src="http://dugnaden.no/wp-content/uploads/2009/10/idrettslag.png" alt="idrettslag" width="90" height="50" />
Idrettslag</h4>
</div>

<div class="knapp" style="float: left;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=korpsogkor&amp;[husk_postnr2]');">
<h4><img title="korpsogkor" src="http://dugnaden.no/wp-content/uploads/2009/10/korpsogkor.png" alt="korpsogkor" width="90" height="50" />
Korps/kor</h4>
</div>

<div class="knapp" style="float: left; padding-top: 0px;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=annen&amp;[husk_postnr2]');">
<h4><img title="annen" src="http://dugnaden.no/wp-content/uploads/2009/10/annen.png" alt="annen" width="90" height="50" />
Annen forening</h4>
</div>

<a href="http://dugnaden.no/produkter/"><img class="size-full wp-image-495" title="Våre produkter" src="http://dugnaden.no/wp-content/uploads/2009/10/produkter2.jpg" alt="Tørkeruller og toalettpapir" width="650" height="390" /></a>
</body></html>

Open in new window


now this is it :D
0
 
LVL 2

Author Comment

by:team2005
ID: 34934548
Now i cant click on the pictures ?

http://dugnaden.no

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934575
some of your mistakes:
onclick="return showPrompt("http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]");"

Open in new window


above you use double quotes also inside the string, that brakes it, you should use it like this:

onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]');"

Open in new window


these empty <a> tags did nothing so i removed them:
<a href="http://dugnaden.no/tjen-penger/?preset=klasse&amp;;[husk_postnr2]"></a>

Open in new window


What you did good and i didn't was with the float left, i user display: inline-table, which only worked in FF..

<div class="knapp" style="float: left;">
<h4><a href="http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]" onclick="return showPrompt("http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]");"><img title="klasse" src="http://dugnaden.no/wp-content/uploads/2009/10/klasse.png" alt="klasse" width="90" height="50" />
Skoleklasse</a></h4></div>

Open in new window


In the above code we want to remove the <a> tag because that if we click it will go to the href adress regardless of what we do, and we don't want that, we want control. So remove the <a> tag and add the onclick event with the adress from <a>'s href and were golden, like in my example posted earlier.

Hope you manage. Good luck!





0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934589
illegal character
[Break On This Error] if (husk_postnr2!=""&#038;&#038;husk_postnr2!=null){

put the cdata characters back cause it transformes the & in the above &#038;..

on this div
 
<div class="knapp" style="float: left;">

Open in new window


add like this:

<div class="knapp" style="float: left; cursor: pointer" >

Open in new window

0
 
LVL 2

Author Comment

by:team2005
ID: 34934601
Hi!

But why cant i click on pictures now ?
Please try yourself:
http://dugnaden.no
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934604
<div id="blog-body">
	<div id="content" class="narrowcolumn">

				<div class="post" id="post-25">
		<h2>Tjen penger på noe alle trenger!</h2>
			<div class="entry">
				<p><html><br />
<head><br />
<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""&#038;&#038;husk_postnr2!=null){
                  /*insert the store script, use what you want*/
                 window.location=href+"&#038;postnr="+husk_postnr2;
	    }
        return false;
    }
//]]&gt;
</script><br />
</head><br />
<body><br />

Open in new window


you can't have 2 head tags!

insert the code below in your main head tag, if you don't do this then the images won't be clickable!

<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""&&husk_postnr2!=null){
                 window.location=href+"&postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>

Open in new window

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934614
could you attach the php file in question so i can edit it more fast?
0
 
LVL 2

Author Comment

by:team2005
ID: 34934617
Hi!

I removed the head tag, but still cant click on pictures

Code i tryed now:


<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""&&husk_postnr2!=null){
                  /*insert the store script, use what you want*/
                 window.location=href+"&postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>

<span style="font-size: 1.4em; line-height: 1.5em;">Vi selger sekker med toalettpapir og tørkeruller som dere kan selge videre gjennom dugnad med god fortjeneste!</span>

MINSTE-BESTILLING 40 SEKKER
<h2>Hvem er dere?</h2>

<div class="knapp" style="float: left;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=klasse&amp;[husk_postnr2]');">
<h4><img title="klasse" src="http://dugnaden.no/wp-content/uploads/2009/10/klasse.png" alt="klasse" width="90" height="50" />
Skoleklasse</h4></div>

<div class="knapp" style="float: left;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=russ&amp;[husk_postnr2]');">
<h4><img title="russ" src="http://dugnaden.no/wp-content/uploads/2009/10/russ.png" alt="russ" width="90" height="50" />
Russ</h4></div>

<div class="knapp" style="float: left;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=idrettslag&amp;[husk_postnr2]');">
<h4><img title="idrettslag" src="http://dugnaden.no/wp-content/uploads/2009/10/idrettslag.png" alt="idrettslag" width="90" height="50" />
Idrettslag</h4>
</div>

<div class="knapp" style="float: left;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=korpsogkor&amp;[husk_postnr2]');">
<h4><img title="korpsogkor" src="http://dugnaden.no/wp-content/uploads/2009/10/korpsogkor.png" alt="korpsogkor" width="90" height="50" />
Korps/kor</h4>
</div>

<div class="knapp" style="float: left; padding-top: 0px;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=annen&amp;[husk_postnr2]');">
<h4><img title="annen" src="http://dugnaden.no/wp-content/uploads/2009/10/annen.png" alt="annen" width="90" height="50" />
Annen forening</h4>
</div>

<a href="http://dugnaden.no/produkter/"><img class="size-full wp-image-495" title="Våre produkter" src="http://dugnaden.no/wp-content/uploads/2009/10/produkter2.jpg" alt="Tørkeruller og toalettpapir" width="650" height="390" /></a>

Open in new window

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934632
I can't be sure that you place all the scripts in the right place, could you please upload the php file so i can take a look at the whole document?
0
 
LVL 2

Author Comment

by:team2005
ID: 34934636
Hi!

The code is not in a php-file.
Its stored in mysql database

I am using CMS system wordpress
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:andreizz
ID: 34934642
<div class="knapp" style="float: left;"
modify the above line into:
<div class="knapp" style="float: left; cursor: pointer;"
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934649
Ok, then just paste the whole text from the database to a text file and upload that.
0
 
LVL 2

Author Comment

by:team2005
ID: 34934650
Tryed that now, now itsshows the pointer cursor..
But cant click on picture ?
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934653
if you click the picture does the prompt appear?
0
 
LVL 2

Author Comment

by:team2005
ID: 34934663
Hi!

No
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934670
ok, then there is something wrong with the javascript, it maybe changed the & or the > < characters or are you sure it is at the top of file in the head tag?
0
 
LVL 2

Author Comment

by:team2005
ID: 34934691
Aha

It dosent like this line in the script:
if (husk_postnr2!=""&&husk_postnr2!=null){

I changed it to:
if (husk_postnr2!=""){

Then it working again, but the page shows this in the url:
http://dugnaden.no/tjen-penger/?preset=klasse#038;postnr=3100

Must be:
http://dugnaden.no/tjen-penger/?preset=klasse&postnr=3100


0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934695
Replace &#038; with &amp;
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934715
another thing, because you edit from admin panel you can't insert anything in the documents <head> tag, that can only done by directly editing your hearder.php file from the wordpress theme directory.

The most correct way to use the script below is to manual edit that file.

<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""&&husk_postnr2!=null){
                 window.location=href+"&amp;postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>

Open in new window


This is how you edit it:
First of all you must have access to the server via ftp or ssh or cpanel.
Navigate to wordpress/wp-content/themes/your_theme_name/header.php

And insert the above code before the </head> tag.
0
 
LVL 2

Author Comment

by:team2005
ID: 34934732
Hi!

Working now, with the included code:

But when i run this in IE, it dosent work


<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""){
                  /*insert the store script, use what you want*/
                 window.location=href+"postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>

<span style="font-size: 1.4em; line-height: 1.5em;">Vi selger sekker med toalettpapir og tørkeruller som dere kan selge videre gjennom dugnad med god fortjeneste!</span>

MINSTE-BESTILLING 40 SEKKER
<h2>Hvem er dere?</h2>

<div class="knapp" style="float: left; cursor: pointer;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=klasse&');">
<h4><img title="klasse" src="http://dugnaden.no/wp-content/uploads/2009/10/klasse.png" alt="klasse" width="90" height="50" />
Skoleklasse</h4></div>

<div class="knapp" style="float: left; cursor: pointer;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=russ&');">
<h4><img title="russ" src="http://dugnaden.no/wp-content/uploads/2009/10/russ.png" alt="russ" width="90" height="50" />
Russ</h4></div>

<div class="knapp" style="float: left; cursor: pointer;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=idrettslag&');">
<h4><img title="idrettslag" src="http://dugnaden.no/wp-content/uploads/2009/10/idrettslag.png" alt="idrettslag" width="90" height="50" />
Idrettslag</h4>
</div>

<div class="knapp" style="float: left; cursor: pointer;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=korpsogkor&');">
<h4><img title="korpsogkor" src="http://dugnaden.no/wp-content/uploads/2009/10/korpsogkor.png" alt="korpsogkor" width="90" height="50" />
Korps/kor</h4>
</div>

<div class="knapp" style="float: left; cursor: pointer; padding-top: 0px;" onclick="return showPrompt('http://dugnaden.no/tjen-penger/?preset=annen&');">
<h4><img title="annen" src="http://dugnaden.no/wp-content/uploads/2009/10/annen.png" alt="annen" width="90" height="50" />
Annen forening</h4>
</div>

<a href="http://dugnaden.no/produkter/"><img class="size-full wp-image-495" title="Våre produkter" src="http://dugnaden.no/wp-content/uploads/2009/10/produkter2.jpg" alt="Tørkeruller og toalettpapir" width="650" height="390" /></a>

Open in new window

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934749
please user this code:
<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""&&husk_postnr2!=null){
                 window.location=href+"&amp;postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>

Open in new window


i see that u didn't change it..

I think you didn't enable activx control in IE, cause it work for me, what IE version do you have?
Try it out in Chrome or Opera or Safari.
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934753
it does that on IE because the statement with !=null is not present, please correct that!
0
 
LVL 2

Author Comment

by:team2005
ID: 34934760
Hi!

If i correct this in the script to:
if (husk_postnr2!=""&&husk_postnr2!=null){

It dosent work ?

Driving me crazy soon

0
 
LVL 2

Author Comment

by:team2005
ID: 34934772
Hi!

Cant use this line in script
if (husk_postnr2!=""&&husk_postnr2!=null){

But i change it to this:

     if (husk_postnr2!=""){
                  /*insert the store script, use what you want*/
                 window.location=href+"postnr="+husk_postnr2;
          }
            if (husk_postnr2!=null){
                  /*insert the store script, use what you want*/
                 window.location=href+"postnr="+husk_postnr2;
          }

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934774
listen to me please the only way to get this properly done is to edit the header.php file in ur theme

this is why:

//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""&#038;&#038;husk_postnr2!=null){
                  /*insert the store script, use what you want*/
                 window.location=href+"postnr="+husk_postnr2;
          }
        return false;
    }
//]]&gt;

see all the strange characters? when you insert javascript in the wordpress editor it parses it and transforms for security reasons all < > & characters

please if you can edit the header file like i said above, if you do that right i guarantee that it will work perfectly.
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934786
if (husk_postnr2!=""){
                  /*insert the store script, use what you want*/
                 window.location=href+"&amp;postnr="+husk_postnr2;
          }
         else
            if (husk_postnr2!=null){
                  /*insert the store script, use what you want*/
                 window.location=href+"&amp;postnr="+husk_postnr2;
          }

make the bolded changes also
0
 
LVL 2

Author Comment

by:team2005
ID: 34934813
Hi!

Aha, so i must then remove the script from the Page
where it is now, and put it in header.php insted ?

0
 
LVL 4

Accepted Solution

by:
andreizz earned 500 total points
ID: 34934827
yes
Navigate to wordpress/wp-content/themes/your_theme_name/header.php

And insert the above code before the </head> tag.

It should something like this at the end:

	/* Always have wp_head() just before the closing </head>
	 * tag of your theme, or you will break many plugins, which
	 * generally use this hook to add elements to <head> such
	 * as styles, scripts, and meta tags.
	 */
	wp_head();
?>
<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""&&husk_postnr2!=null){
                 window.location=href+"&postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>
</head>

Open in new window


Please insert the following code:
<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
            if (husk_postnr2!=""&&husk_postnr2!=null){
                 window.location=href+"&postnr="+husk_postnr2;
	    }
        return false;
    }
//]]>
</script>

Open in new window

0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934843
I look at the page and you didn't put what i said, please follow my instructions strictly or we will never be done..
0
 
LVL 2

Author Comment

by:team2005
ID: 34934846
Hi!

Now i put the script in header.php
With this code:
<script type="text/javascript">
//<![CDATA[
    var showPrompt = function(href){
     husk_postnr2=prompt("Legg inn postnummer");
     
         if (husk_postnr2!=""){
                  /*insert the store script, use what you want*/
                 window.location=href+"&amp;postnr="+husk_postnr2;
          }
         else
            if (husk_postnr2!=null){
                  /*insert the store script, use what you want*/
                 window.location=href+"&amp;postnr="+husk_postnr2;
          }
        return false;
    }
//]]>
</script>

After i input the number its showing this url:
http://dugnaden.no/tjen-penger/?preset=klasse&postnr=3100

???
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934856
Please read my previous posts and redo the part with header.php, the code that you inserted has flaws i won't go into details but please do it.
0
 
LVL 2

Author Closing Comment

by:team2005
ID: 34934891
Thanks
0
 
LVL 4

Expert Comment

by:andreizz
ID: 34934898
Good luck!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now