Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass variable from js to iframe ?

Status
Not open for further replies.

buztwet

IS-IT--Management
May 1, 2003
46
0
0
US
I am definitely not a javascript programmer, but I'm trying here. This is what I have:
var augArray = new Array();
var the_date = new Date();
var the_day = the_date.getDate();
var the_month = the_date.getMonth();
var htmmo = 'DailyDevotions/August/aug';
var htmday = the_day;
var htmend = '.htm';
var total = htmmo + htmday+ htmend;

if (the_month=7){
augArray[the_day] = '<iframe width=500 height=600 frameborder="0" src=total></iframe>';
}

I know this will not work since the iframe doesn't know what 'total' is but I was wondering if there's anyway to fix this.
 

You need to use a double equals ( == ) instead of a single equals ( = ) in your "if" statement. So change this:

Code:
if (the_month=7){

to this:

Code:
if (the_month == 7){

Hope this helps,
Dan
 
Thanks for the tip, but I still need to get the program to recognize that the total variable is a variable and not a source file. Any other ideas?
 
buztwet,
Code:
    var augArray = new Array();
    var the_date = new Date();
    var the_day = the_date.getDate();
    var the_month = the_date.getMonth();
    var htmmo = 'DailyDevotions/August/aug';
    var htmday = the_day;
    var htmend = '.htm';
    var total = htmmo + htmday+ htmend;

if (the_month=7){
augArray[the_day] = '<iframe width=500 height=600 frameborder="0" src="' + total + '"></iframe>';
}

This will pass the string into the variable
augArray[the_day].

Was that the goal?

Great Javascript Resource:
 
if u want the page in the iframe to access any particular field in the parent page try this, in the iframe page:
alert(window.parent.JS_VARIABLE_NAME)

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top