Help needed with this Javascript code

J

John

Hi all,
Can anyone help with this please?
Firstly, here is the code....

<script type="text/javascript">
var b = Request.QueryString("page")+".htm";
var a='"';
var productstoshow=a+b+a;
document.getElementById('productlist').src=productstoshow;
document.frames['productlist'].location.reload(true);
</script>

The variable 'productstoshow' contains the full name of a web page as well as the quotes.....eg
"test.htm"
I have an iFrame called 'productlist'

What the last two lines of code is suppose to do is change the 'src=' value of the iFrame, and
reload it containing the new htm page but it doesn't.
I have searched for and tried other variations but none work.
Any ideas anyone?
TIA.
 
S

Steve Easton

There's no function in your script.
You need to create a function and then use some event to "Fire" the function,
and then you need to wrap the instructions for the function to perform in curly braces {}

<script type="text/javascript">
function dothis(){
var b = Request.QueryString("page")+".htm";
var a='"';
var productstoshow=a+b+a;
document.getElementById('productlist').src=productstoshow;
document.frames['productlist'].location.reload(true);
}
</script>

Then somewhere in your page you need to fire the function

<body onload="dothis()">

Or by using an onclick in some clickable element in the page

onclick="dothis()"


--
Steve Easton
Microsoft MVP FrontPage
FP Cleaner
http://www.95isalive.com/fixes/fpclean.htm
Hit Me FP
http://www.95isalive.com/fixes/HitMeFP.htm
 
R

Ronx

In addition,
Change
var b = Request.QueryString("page")+".htm";
var a='"';
var productstoshow=a+b+a;

to
var productstoshow = Request.QueryString("page")+".htm";

Quotes are only needed to delimit text, not string variables - your exiting
script is trying to load a page that has quotes as part of the filename.
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/

Steve Easton said:
There's no function in your script.
You need to create a function and then use some event to "Fire" the
function,
and then you need to wrap the instructions for the function to perform in
curly braces {}

<script type="text/javascript">
function dothis(){
var b = Request.QueryString("page")+".htm";
var a='"';
var productstoshow=a+b+a;
document.getElementById('productlist').src=productstoshow;
document.frames['productlist'].location.reload(true);
}
</script>

Then somewhere in your page you need to fire the function

<body onload="dothis()">

Or by using an onclick in some clickable element in the page

onclick="dothis()"


--
Steve Easton
Microsoft MVP FrontPage
FP Cleaner
http://www.95isalive.com/fixes/fpclean.htm
Hit Me FP
http://www.95isalive.com/fixes/HitMeFP.htm


John said:
Hi all,
Can anyone help with this please?
Firstly, here is the code....

<script type="text/javascript">
var b = Request.QueryString("page")+".htm";
var a='"';
var productstoshow=a+b+a;
document.getElementById('productlist').src=productstoshow;
document.frames['productlist'].location.reload(true);
</script>

The variable 'productstoshow' contains the full name of a web page as
well as the quotes.....eg
"test.htm"
I have an iFrame called 'productlist'

What the last two lines of code is suppose to do is change the 'src='
value of the iFrame, and
reload it containing the new htm page but it doesn't.
I have searched for and tried other variations but none work.
Any ideas anyone?
TIA.
 
S

Stefan B Rusynko

ASP is not supported in JavaScript w/o VBscript delimiters
the ASP request should be processed before the JavaScript and then the JavaScript can use the variable created by it
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| In addition,
| Change
| var b = Request.QueryString("page")+".htm";
| var a='"';
| var productstoshow=a+b+a;
|
| to
| var productstoshow = Request.QueryString("page")+".htm";
|
| Quotes are only needed to delimit text, not string variables - your exiting
| script is trying to load a page that has quotes as part of the filename.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
| FrontPage Support: http://www.frontpagemvps.com/
|
| | > There's no function in your script.
| > You need to create a function and then use some event to "Fire" the
| > function,
| > and then you need to wrap the instructions for the function to perform in
| > curly braces {}
| >
| > <script type="text/javascript">
| > function dothis(){
| > var b = Request.QueryString("page")+".htm";
| > var a='"';
| > var productstoshow=a+b+a;
| > document.getElementById('productlist').src=productstoshow;
| > document.frames['productlist'].location.reload(true);
| > }
| > </script>
| >
| > Then somewhere in your page you need to fire the function
| >
| > <body onload="dothis()">
| >
| > Or by using an onclick in some clickable element in the page
| >
| > onclick="dothis()"
| >
| >
| > --
| > Steve Easton
| > Microsoft MVP FrontPage
| > FP Cleaner
| > http://www.95isalive.com/fixes/fpclean.htm
| > Hit Me FP
| > http://www.95isalive.com/fixes/HitMeFP.htm
| >
| >
| > | >> Hi all,
| >> Can anyone help with this please?
| >> Firstly, here is the code....
| >>
| >> <script type="text/javascript">
| >> var b = Request.QueryString("page")+".htm";
| >> var a='"';
| >> var productstoshow=a+b+a;
| >> document.getElementById('productlist').src=productstoshow;
| >> document.frames['productlist'].location.reload(true);
| >> </script>
| >>
| >> The variable 'productstoshow' contains the full name of a web page as
| >> well as the quotes.....eg
| >> "test.htm"
| >> I have an iFrame called 'productlist'
| >>
| >> What the last two lines of code is suppose to do is change the 'src='
| >> value of the iFrame, and
| >> reload it containing the new htm page but it doesn't.
| >> I have searched for and tried other variations but none work.
| >> Any ideas anyone?
| >> TIA.
| >>
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top