Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2004, 02:47 AM
Authorized User
 
Join Date: Sep 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to add a javascript within a iframe's tag ?

I have iframe's tag as below:

<iframe name="booklst" src="BookLst.jsp?acctno=<%= acctno %>&price=<%= price %>"></iframe>


My question is, instead of using a jsp expression tag "price=<%= price %>", could we replace the statement with a javascript statement, within the iframe html tag?

Thanks in advanced.

 
Old September 28th, 2004, 03:19 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You cannot replace it with a client-side script expression. You could modify the src attribute from a client-side script block elsewhere in the page but you would have to know or be able to receive the account number and price from somewhere:
Code:
function modifyIframeSrc(IframeName, Src)
{
  var oFrame = document.getElementsByName(IFrameName)[0];
  oFrame.src = Src;
}

function getAccountSrc(AccountNumber, Price)
{
  var sSrc = "BookLst.jsp?acctno=" + AccountNumber + "&price=" + Price;
  return sSrc; 
}
Then somewhere you need to call:
Code:
var sAccountNumber = "=<%= acctno %>";
var sPrice = "=<%= price %>";
modifyIframeSrc("booklst", getAccountSrc(sAccountNumber , sPrice));
or you may have other ways of retrieving the details.
You still may need to force a refresh of the iframe for the new page to show properly.
--

Joe
 
Old September 28th, 2004, 04:25 AM
Authorized User
 
Join Date: Sep 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your advices are valueable. Thanks a lot, joe.






Similar Threads
Thread Thread Starter Forum Replies Last Post
add id tag with setAttribute generates escape char neilstairmand Javascript 1 June 6th, 2007 05:18 PM
HTML tag from C# or ASP.NET tag from javascript angshujit ASP.NET 2.0 Basics 3 February 16th, 2007 10:07 AM
VBSCRIPT in between JAVASCRIPT and an INPUT TAG Pr shookim Javascript 2 February 13th, 2006 10:48 AM
Javascript in Anchor Tag jamara JSP Basics 1 May 30th, 2005 01:00 AM
can't read value from select tag using javascript kumar_kumar Javascript 2 February 9th, 2005 11:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.