Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

iframe in asp

Posted on 2015-02-11
3
Medium Priority
?
237 Views
Last Modified: 2015-02-11
I have an asp page that is linked using session variables( so  link.com/doc_choose.asp?cat=5). I can display an iframe with no problem using a script such as:

<script type="text/javascript">
						 

if (1 < 1100) 
{
document.write('<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>'); 
}

else
{

document.write('<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>'); 
}
</script>  

Open in new window



I want to show the iframe only on certain pages and not all. How can I get that session variable to work? If I do this:

     
 <%
    gotcat = Request.querystring("cat")
%>

Open in new window


I can not use the gotcat variable  in my script above. Also if I use this code

   
  <%
    gotcat = Request.querystring("cat")
	if gotcat < 6 Then 
	document.Write(<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>)
	end if
%>

Open in new window



Then I get this error:

Microsoft VBScript compilation error '800a03ea'

Syntax error

/doc_choose.asp, line 90

document.Write(<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>)
---------------^


So how can I see the variable that is passed to display an iFrame?


Thanks so much
0
Comment
Question by:Biofilminc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 2000 total points
ID: 40604607
iframes, wow! my first recommendation would be to get rid of such an outdated technology! :)

given that's not an option, your problem is you're mixing client side and server side code incorrectly. try this:

<%
    gotcat = Request.querystring("cat")
    if gotcat = "" or not isNumeric( gotcat ) then gotcat = 0
%>
<script type="text/javascript">
						 
var gotcat = <%=gotcat%>;

//-- now you can do your if statement
if( gotcat == 6 ) 
{
document.write('<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>'); 
}

else
{

document.write('<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>'); 
}
</script>  

Open in new window

0
 

Author Comment

by:Biofilminc
ID: 40604616
I have no choice. Its an old intranet. I get what I get sadly.

That solved it. I knew I was mixing languages but didn't know how to make the variable work across both.

var gotcat = <%=gotcat%>;     <<<<< That was what was holding me up.  Thanks so much.
0
 

Author Closing Comment

by:Biofilminc
ID: 40604617
Perfect and easy.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

718 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