Link to home
Start Free TrialLog in
Avatar of team2005
team2005

asked on

My website popupwindow dosent work now ?

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 ?
Avatar of andreizz
andreizz
Flag of Romania image

<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?
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..
Avatar of team2005
team2005

ASKER

Whys dosent it work on my computer ?

I am using Firefox

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

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.

Hi!

How do i send this to url then ?
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

post the code you have so far, including the <html></html> tags and i will modify it for you.
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

<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

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



<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
Now i cant click on the pictures ?

http://dugnaden.no

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!





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

Hi!

But why cant i click on pictures now ?
Please try yourself:
http://dugnaden.no
<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

could you attach the php file in question so i can edit it more fast?
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

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?
Hi!

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

I am using CMS system wordpress
<div class="knapp" style="float: left;"
modify the above line into:
<div class="knapp" style="float: left; cursor: pointer;"
Ok, then just paste the whole text from the database to a text file and upload that.
Tryed that now, now itsshows the pointer cursor..
But cant click on picture ?
if you click the picture does the prompt appear?
Hi!

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


Replace &#038; with &amp;
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.
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

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.
it does that on IE because the statement with !=null is not present, please correct that!
Hi!

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

It dosent work ?

Driving me crazy soon

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

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.
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
Hi!

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

ASKER CERTIFIED SOLUTION
Avatar of andreizz
andreizz
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I look at the page and you didn't put what i said, please follow my instructions strictly or we will never be done..
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

???
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.
Thanks
Good luck!