Click to See Complete Forum and Search --> : Iframe Javascript Table link Help


Kamal_Hi_tek
09-19-2003, 10:27 PM
I'm having problem with this code. I have Iframe and suppose to show the frame1 with this code names in a table where you could click and information showing on the other frame2.

Please let me know any suggestions.
thanx
Here's the code...Note: This is just the frame1 code, which doesn't show nothing at all.

<HTML>
<HEAD>
<TITLE>Frameset Address List</TITLE>
<style><!--
BODY, TD {font-family:Verdana, Arial, sans-serif; font-size:9pt;}
-->
</style>

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--

//--------------------------------------------------------------------------
/**
* function displayDetail(index)
* Display a Detailed Line
*
* @param integer index the index into the people array
*/
function displayDetail(index) {
retVal=
"<table bgcolor='#7596B8' border='0' cellpadding='0' cellspacing='0'>"
+ "<tr><td>" +
"<table border='0' cellpadding='10' cellspacing='1'>"
+ "<tr><td bgcolor='#F7F9F9'>";
retVal += myList[index]['lastName'];
retVal += "\n<br>Put in last name and <br>practice adding fake stuff"
+ <br>(e.g. address, etc.) here";
retVal += "</td>\n</tr>\n</table>"; // get rid for class
retVal += "</td>\n</tr>\n</table>"; // get rid for class close outer table

writeContent(retVal);
}
//--------------------------------------------------------------------------
/**
* function writeContent(pageContent)
* Writes the HTML string to the second frame
*
* @param string pageContent the HTML we want to send to the detail frame
* @return nothing
*/
function writeContent(pageContent) {
content = "<HTML>\n<HEAD>";
content += "\n<style><!--";
content += "\nBODY, TD {font-family:Verdana,Arial,sans-serif;" +
" font-size:9pt;}";
content += "\n--\>";
content += "\n</style>";
content += "\n<\/HEAD><BODY bgcolor='white'>";
content += "\n<H1>Detailed Information<\/H1>" + pageContent;
content += "\n<\/BODY><\/HTML>";
//alert ("content=\n" + content);
parent.content.document.write(content);
parent.content.document.close();
}


myList=new Array();
myList[0]={firstName:"John", lastName:"Jones"};
myList[1]={firstName:"Pat", lastName: "Johnson"};
myList[2]={firstName:"Chris", lastName: "Smith"};
myList[3]={firstName:"Jody", lastName: "Adams"};
myList[4]={firstName:"Bob", lastName: "Owens"};


// End hiding script from old browsers -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="WHITE" >
<H1 ALIGN="CENTER">My Addresses</H1>
<P ALIGN="CENTER">
<table><tr><td valign="top">


<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
// now start creating the list in the left nav

document.write ("<br><b>Address List</b>");

for (myList) {
document.write ("\n<br><a href='javascript:displayDetail(" + entry + ")'>"
+ myList[entry]['lastName'] + "</a> " +myList[entry]['firstName'] );
}

//-->
</SCRIPT>
</td></tr></table>

</BODY>
</HTML>

Khalid Ali
09-20-2003, 07:21 AM
Please re-phrase your question....

Kamal_Hi_tek
09-20-2003, 09:29 AM
Khalid salaam brother, what I'm asking for is i have this code to display arrays table list of names. Now as you can see in the code, the list of name will be displayed on the leftside frame and not only that but at the sametime each name becomes a link, when you clicked, detailed information suppose to display on rightside frame2. In another words, I'm using frameset and this is part of it..

I hope this clears up and I appologize any confusion
Please le me know.
Thankx

Khalid Ali
09-20-2003, 09:37 AM
In simple words,you ahve link in one frame,and when clicked ton those links you want the details to appear in the second frame?

if so then you need to direct the results to the second frame.

to target results to second frame you can use this

parent.frameName.document.write(results)

Kamal_Hi_tek
09-20-2003, 10:47 AM
Ok, now you do understand what i was talking bout. Now firs to start with, I'm having problem do display the names on left nav frame and getting error.

Any help....
thanx

Khalid Ali
09-20-2003, 11:23 AM
your code..well lets not say anything about it..:-)

Can you zip all of the resources(all of the frames and iframes resources) and upload them to this forum with this thread..so that I can take a look at the stuf and make apropriate changes

Kamal_Hi_tek
09-20-2003, 11:46 AM
Here's the first one. it's saved as menu.html and it's the left Nav.

<HTML>
<HEAD>
<TITLE>Frameset Address List</TITLE>
<style><!--
BODY, TD {font-family:Verdana, Arial, sans-serif; font-size:9pt;}
-->
</style>

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--

//--------------------------------------------------------------------------
/**
* function displayDetail(index)
* Display a Detailed Line
*
* @param integer index the index into the people array
*/
function displayDetail(index) {
retVal=
"<table bgcolor='#7596B8' border='0' cellpadding='0' cellspacing='0'>";
+ "<tr><td>" +
"<table border='0' cellpadding='10' cellspacing='1'>"
+ "<tr><td bgcolor='#F7F9F9'>";
retVal += myList[index]['lastName'];
retVal += "\n<br>Put in last name and <br>practice adding fake stuff"
+ <br>(e.g. address, etc.) here";
retVal += "</td>\n</tr>\n</table>"; // get rid for class
retVal += "</td>\n</tr>\n</table>"; // get rid for class close outer table

writeContent(retVal);
}
//--------------------------------------------------------------------------
/**
* function writeContent(pageContent)
* Writes the HTML string to the second frame
*
* @param string pageContent the HTML we want to send to the detail frame
* @return nothing
*/
function writeContent(pageContent) {
content = "<HTML>\n<HEAD>";
content += "\n<style><!--";
content += "\nBODY, TD {font-family:Verdana,Arial,sans-serif;" +
" font-size:9pt;}";
content += "\n--\>";
content += "\n</style>";
content += "\n<\/HEAD><BODY bgcolor='white'>";
content += "\n<H1>Detailed Information<\/H1>" + pageContent;
content += "\n<\/BODY><\/HTML>";
//alert ("content=\n" + content);
parent.content.document.write(content);
parent.content.document.close();
}


myList=new Array();
myList[0]={firstName:"John", lastName:"Jones"};
myList[1]={firstName:"Pat", lastName: "Johnson"};
myList[2]={firstName:"Chris", lastName: "Smith"};
myList[3]={firstName:"Jody", lastName: "Adams"};
myList[4]={firstName:"Bob", lastName: "Owens"};


// End hiding script from old browsers -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="WHITE" >
<H1 ALIGN="CENTER">My Addresses</H1>
<P ALIGN="CENTER">
<table><tr><td valign="top">


<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
// now start creating the list in the left nav

document.write ("<br><b>Address List</b>");

for (myList) {
document.write ("\n<br><a href='javascript:displayDetail(" + entry + ")'>"
+ myList[entry]['lastName'] + "</a> " +myList[entry]['firstName']
);
}

//-->
</SCRIPT>
</td></tr></table>

</BODY>
</HTML>

Then here is a blank.html, which is the blank page that shows nothing unless you clicked the left nav menu table.

<HTML>
<HEAD>
<TITLE>Frameset Address List</TITLE>
<style><!--
BODY, TD {font-family:Verdana, Arial, sans-serif; font-size:9pt;}
-->
</style>
</HEAD>
<BODY>
<br>
Click on a name to get their detailed information.
</BODY>
</HTML>

last but not least is the frameset.html, which is the main page and calls/assign the different frames.

<HTML>
<HEAD>
<TITLE>Frameset Address List</TITLE>
</HEAD>
<FRAMESET COLS="200,*">
<FRAME SRC="menu.html" NAME="left">
<FRAME NAME="content" SRC="blank.html">
</FRAMESET>
</HTML>


I hope you get it by now because I do really need help in this and i'm a beginer.

Thanx.

Khalid Ali
09-20-2003, 12:14 PM
Originally posted by Kamal_Hi_tek


for (myList) {
document.write ("\n<br><a href='javascript:displayDetail(" + entry + ")'>"
+ myList[entry]['lastName'] + "</a> " +myList[entry]['firstName']
);
}




Replace the loop code above with the one below

for (entry in myList) {
document.write ("\n<br><a href='#' onclick='displayDetail(" + entry + ");return false;'>"
+ myList[entry]['lastName'] + "</a> " +myList[entry]['firstName']
);
}

this should take care of it

Kamal_Hi_tek
09-20-2003, 12:24 PM
Khalid, I did as you told me but now am getting the error myList is undefined, so let me know if the whole thing has worked for you.

Thanx
I appreciated.

Khalid Ali
09-20-2003, 02:34 PM
I have the example code working at the link below

http://68.145.35.86/temp/Kamal_Hi_tek/frameset.html

Kamal_Hi_tek
09-20-2003, 02:58 PM
Khalid I thank you very much...you're the man, but I still have more question...

Now I want the left nav names in table and instead of the one name being linked, I want the whole name..both first and last name. Also Add more detailed information on each name when clicked.

Once again,
Thanx

Khalid Ali
09-20-2003, 03:14 PM
You have to take a look at the code and see what I have done to get what you wanted, so that you can understand that part.

I have updated so that it shows the full name(last, first).
FOr the detailed inofrmation,you willhave to write an array of data,which points to name for the information

Kamal_Hi_tek
09-20-2003, 08:19 PM
Khalid, I did look at the Code and want to thank you for that. Now what I would like to do is display information for each name after it's being clicked. As you can see, now it same info for all of the names.

Any help would be appreciated.

Thanx