We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Simple javascript Q

Medium Priority
317 Views
Last Modified: 2013-11-19
Hello experts,


I have a small problem.. I have a form that calls the following function;-

<script language="javascript">
function openZoom(which, pid)
{
      var newWindow=window.open("zoommattress.asp?prod=<%=pid%>","","width=675,height=475,resizable=0,status=yes,scrollbars=yes,screenX=100,screenY=100,top=100,left=100'");
      
}


</script>

This is where I call the function
<div class="imagebox"><a href="javascript:openZoom(2, <%=Product.product_id%>);"><img src="images/medium/<%=Product.image_medium%>" alt="<%=MyCategory.cat_name%> - <%=Product.name%>" width="140" border="0"class="border"/></a></div>


I know that 'Product.product_id' has a value cos when I do an alert(pid) it displays the correct product_id

But for some reason there is no value for pid on this line;-
var newWindow=window.open("zoommattress.asp?prod=<%=pid%>"

many thanks
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Hi claracruz,
instead
> newWindow=window.open("zoommattress.asp?prod=<%=pid%>",...
use
window.open("zoommattress.asp?prod="+pid+",...

what you try to do is to use server side var on client side script - this cannot be done this way...

check with
alert(pid);

HTH

I

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
in javascript we dont use <%=
try this

<script language="javascript">
function openZoom(which, pid)
{
     var newWindow=window.open("zoommattress.asp?prod="+pid,"","width=675,height=475,resizable=0,status=yes,scrollbars=yes,screenX=100,screenY=100,top=100,left=100'");
     
}


</script>
Pravin AsarPrincipal Systems Engineer
CERTIFIED EXPERT
Top Expert 2005

Commented:
What is the purpose of passing which ???

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.