473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

populating webpage elements with contents of an iframe

Hi friends,

I am developing a web application using Jsp and JS.

I have a main Jsp page(Jsp1).Inside it I have an iframe having an Html-
table which is created dynamically and contains all records from the
backend-table . For creating this dynamic table I've used another
Jsp(Jsp2) and in Jsp1 I say:
<iframe id = "I1" src="Jsp2.jsp" width=320 scrolling="yes">

Now I have links on every row of the table and the link is used to
select a particular row for modifying it.User can select one row at a
time.
For eg on clicking a link on the name 'Mr.Jack Brown' from the table
in the iframe I need that the info of 'Jack Brown' be populated into
the corresponding fields of the main Jsp(Jsp 1) i.e in 'Student Name-
textbox' it should show 'Mr.Jack Brown', in 'Batch ID-textbox' it
should show '1' etc .

Here's a snapshot of Jsp1:-
http://www.thescripts.com/forum/atta...tachmentid=138

Is it possible that I can actually populate the elements of the parent
window with data(fields) from the table present in the iframe or is
there any other way of achieving this?

Any suggestions much appreciated !

Jan 29 '07 #1
6 2479
First of all i would suggest moving away from iframes but since you
have them. Also I am not a jsp expert by any means. I think the answer
you are looking for is displayed in my example below I will recap to
make sure I understand.

jsp1.jsp:
<html>
<body>
<iframe src=jsp2.jsp></iframe>
</body>
</html>

jsp2.jsp

<a href="jsp1.jsp?id= + <%jspcode to identy record%>"
target="_parent">Mr. Jack Brown</a>

let me know if that makes since!

Jan 30 '07 #2
On Jan 30, 10:27 am, "Adambrz" <Adam...@msn.comwrote:
First of all i would suggest moving away from iframes but since you
have them. Also I am not a jsp expert by any means. I think the answer
you are looking for is displayed in my example below I will recap to
make sure I understand.

jsp1.jsp:
<html>
<body>
<iframe src=jsp2.jsp></iframe>
</body>
</html>

jsp2.jsp

<a href="jsp1.jsp?id= + <%jspcode to identy record%>"
target="_parent">Mr. Jack Brown</a>

let me know if that makes since!
-----------------------------------------------------------------------
-----------------------------------------------------------------------
--------------------------------------
Hi and Thanks for your reply, well I gave up the idea of working with
iframe and now I'm creating&displaying a dynamic table on Jsp1 itself,
also I discarded the idea of using links; now what I have is as
below:-

The dynamic table is placed inside a <divon Jsp1 and it has vertical
scrollbar. Each row in this table has a radio button associated with
it which is used to select a particular row for modifying it.User can
select a single row at a time.So now I want that if I select the radio
button on say the 3rd row then the cell-contents of the third row
should be populated in the corresponding textfields of Jsp1.

I am totally clueless as to how to determine which row it is that has
its radio button clicked and how to retrieve individual cell values of
the table and set them as text in the textboxes on Jsp1?! Any ideas?

Jan 30 '07 #3
Your killin' me! Just kidding. Doesn't sound to difficult.

It looks like you will create your table with jsp and the radio on
creation should the value should be declared. So I image it would look
something like this:
<body>
<form id="form1" name="form1" method="get" action="JSP1.jsp">
<table>
<%jsp to start loop to create radio button for each record%>
<tr><td>
<input type="radio" name="id" value="<%jsp code for ID%>"
onChange="javascript:document.form1.submit();" />
</td><td><%JSP to write Mr. Jack Brown</td>
</tr>
<%jsp for end of loop to go to next record%>
</table>
</form>
you should see that the form on submit to the same page. What will
happen is when radio button is selected i will auto submit the form to
the same page with the address being "JSP1.jsp?id=1234" or whatever
your id number is. I know php so i will just write out what I would do
for that to work.

Check to so if url param is set.
if set query database with id set to url param
fillin value of jsp1 form with those values.

Hope this helps and makes since feel free to ask any questions.

Jan 30 '07 #4
On Jan 31, 1:01 am, "Adambrz" <Adam...@msn.comwrote:
Your killin' me! Just kidding. Doesn't sound to difficult.

It looks like you will create your table with jsp and the radio on
creation should the value should be declared. So I image it would look
something like this:
<body>
<form id="form1" name="form1" method="get" action="JSP1.jsp">
<table>
<%jsp to start loop to create radio button for each record%>
<tr><td>
<input type="radio" name="id" value="<%jsp code for ID%>"
onChange="javascript:document.form1.submit();" />
</td><td><%JSP to write Mr. Jack Brown</td>
</tr>
<%jsp for end of loop to go to next record%>
</table>
</form>

you should see that the form on submit to the same page. What will
happen is when radio button is selected i will auto submit the form to
the same page with the address being "JSP1.jsp?id=1234" or whatever
your id number is. I know php so i will just write out what I would do
for that to work.

Check to so if url param is set.
if set query database with id set to url param
fillin value of jsp1 form with those values.

Hope this helps and makes since feel free to ask any questions.
-----------------------------------------------------------------------
-----------------------------------------------------------------------
----------------------------------------------
Hi Adambrz
Thanks for your time and response,

A snapshot of my webpage is located here:-
http://www.dynamicdrive.com/forums/attachment.php?
attachmentid=758&d=1170187911

It's a Jsp and on it I have a table (say T1) which is created
dynamically and contains all the backend-table's records as rows. I am
creating this dynamic table inside a <divon Jsp1 and using a Jsp-
scriptlet to get the backend data into the table. I have set a
vertical scrollbar on the <divsuch that user can see 4 rows of T1 at
a time. Each row in T1 has a radio button associated with it which is
used to select a particular row for modifying it. User can select a
single row at a time.

The requirement is that if I select the radio button on any row then
the cell-contents of that row should be populated in the corresponding
textfields of Jsp1.

For eg: if the user clicks the radio of the 3rd row then 'Student Name-
textfield' should show "Mr.Jonathan Brown"; 'Batch-ID-textfield'
should show "1" etc i.e. every textfield should be populated with the
corresponding cell value of the row.

I have grouped the radio-buttons and the group-name is "Group" but I
am totally clueless as to how to determine which row it is that has
its radio clicked and how to retrieve individual cell values of the
table and set them as text in the textfields of Jsp1?!

This is somewhat how my entire webpage(JSP) looks like in brief:-

<%@ page language = "JAVA" import = "java.sql.*" %>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title></title>
<style type=text/css>
# divStayTopLeft{
height:100px;
width:400px;
border:1px;
}
table.T1{
text-align:center;
font-weight:bold;
float:right;
width:450px;
}
. highlighted{
background-color:#ffffcc;
border:1px solid black;
}
</style>
<script language = "javascript">
// some clientside validation code
</script>
</head>
<body>
<form name = "Students">
<table>
<!-This is the main layout table and I have fixed my entire webpage in
to this table -->
</table>
</form>
<script>
document.write('<div id="divStayTopLeft"
style="position:absolute;overflow:scroll">')
</script>
<div id="divStayTopLeft">
<%
PreparedStatement pst ;
ResultSet rs = null ;
try
{
pst = con.prepareStatement("select * from
Students");
rs = pst.executeQuery();

if (rs != null)
{
out.write("<table class = \"T1\" id = \"TId\" border =
\"1\" cellspacing=0 cellpadding=2>");
out.write("<tr>");
out.write("<th bgcolor=lightgrey>Candidate Name</th>");
out.write("<th bgcolor=lightgrey>Batch-ID</th>");
out.write("<th bgcolor=lightgrey>Reg Amt</th>");
out.write("<th bgcolor=lightgrey>Total Fees </th>");
out.write("<th bgcolor=lightgrey>Balance</th>");
out.write("</tr>");

// Here I have the code for getting the backend record and appending
it to the dynamically created table T1
while(rs.next())
{
out.write("<tr<td bgcolor=#ECF9FF
nowrap><input type=\"radio\" value=\"V\" checked name=\"Group\"><b>" +
rs.getString(1) + "</b></a></td>");
out.write("<td>" + rs.getInt(2) + "</
td>");
out.write("<td>" + rs.getLong(3) +
"</td>");
out.write("<td>" + rs.getLong(4) +
"</td>");
out.write("<td>" + rs.getLong(5)+ "</
td></tr>");
}
out.write("</table>");
}
rs.close();
pst.close();
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</div>
</body>
</html>

Any assistance from anyone is greatly appreciated !
Jan 30 '07 #5

Realize with my lack of JSP knowledge i am going to take a shot in the
dark here.
-----------------------------------------------------------------------
------------------------------------------------
On Jan 30, 3:59 pm, "eureka" <mseur...@rediffmail.comwrote:
On Jan 31, 1:01 am, "Adambrz" <Adam...@msn.comwrote:
Your killin' me! Just kidding. Doesn't sound to difficult.
It looks like you will create your table with jsp and the radio on
creation should the value should be declared. So I image it would look
something like this:
<body>
<form id="form1" name="form1" method="get" action="JSP1.jsp">
<table>
<%jsp to start loop to create radio button for each record%>
<tr><td>
<input type="radio" name="id" value="<%jsp code for ID%>"
onChange="javascript:document.form1.submit();" />
</td><td><%JSP to write Mr. Jack Brown</td>
</tr>
<%jsp for end of loop to go to next record%>
</table>
</form>
you should see that the form on submit to the same page. What will
happen is when radio button is selected i will auto submit the form to
the same page with the address being "JSP1.jsp?id=1234" or whatever
your id number is. I know php so i will just write out what I would do
for that to work.
Check to so if url param is set.
if set query database with id set to url param
fillin value of jsp1 form with those values.
Hope this helps and makes since feel free to ask any questions.

-----------------------------------------------------------------------
-----------------------------------------------------------------------
----------------------------------------------
Hi Adambrz
Thanks for your time and response,

A snapshot of my webpage is located here:-http://www.dynamicdrive.com/forums/attachment.php?
attachmentid=758&d=1170187911

It's a Jsp and on it I have a table (say T1) which is created
dynamically and contains all the backend-table's records as rows. I am
creating this dynamic table inside a <divon Jsp1 and using a Jsp-
scriptlet to get the backend data into the table. I have set a
vertical scrollbar on the <divsuch that user can see 4 rows of T1 at
a time. Each row in T1 has a radio button associated with it which is
used to select a particular row for modifying it. User can select a
single row at a time.

The requirement is that if I select the radio button on any row then
the cell-contents of that row should be populated in the corresponding
textfields of Jsp1.

For eg: if the user clicks the radio of the 3rd row then 'Student Name-
textfield' should show "Mr.Jonathan Brown"; 'Batch-ID-textfield'
should show "1" etc i.e. every textfield should be populated with the
corresponding cell value of the row.

I have grouped the radio-buttons and the group-name is "Group" but I
am totally clueless as to how to determine which row it is that has
its radio clicked and how to retrieve individual cell values of the
table and set them as text in the textfields of Jsp1?!

This is somewhat how my entire webpage(JSP) looks like in brief:-

<%@ page language = "JAVA" import = "java.sql.*" %>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title></title>
<style type=text/css>
# divStayTopLeft{
height:100px;
width:400px;
border:1px;
}
table.T1{
text-align:center;
font-weight:bold;
float:right;
width:450px;
}
. highlighted{
background-color:#ffffcc;
border:1px solid black;
}
</style>
<script language = "javascript">
// some clientside validation code
</script>
</head>
<body>
<form name = "Students">
<table>
<!-This is the main layout table and I have fixed my entire webpage in
to this table -->
</table>
</form>
<script>
document.write('<div id="divStayTopLeft"
style="position:absolute;overflow:scroll">')
</script>
<div id="divStayTopLeft">
<%
PreparedStatement pst ;
ResultSet rs = null ;

//create variables that are empty to fill into your form
String name = "";
int myint = null;
long mylong = null;
// check to see if url param is set. This is in php code so
you will have to adapt to jsp

if(isset($_GET['id']){
PreparedStatement pst2 ;
ResultSet rs2 = null ;
pst2 = con.prepareStatement("select * from Students WHERE
id=$_GET['id']");
rs2 = pst.executeQuery();
}
//then set these variables equal to the field in the form
name = rs.getString(1) ;
//ect..
try
{
pst = con.prepareStatement("select * from
Students");
rs = pst.executeQuery();

if (rs != null)
{
out.write("<table class = \"T1\" id = \"TId\" border =
\"1\" cellspacing=0 cellpadding=2>");

out.write(" <form id="radioform" name="radioform"
method="get" action="jsp1.jsp">");

out.write("<tr>");
out.write("<th bgcolor=lightgrey>Candidate Name</th>");
out.write("<th bgcolor=lightgrey>Batch-ID</th>");
out.write("<th bgcolor=lightgrey>Reg Amt</th>");
out.write("<th bgcolor=lightgrey>Total Fees </th>");
out.write("<th bgcolor=lightgrey>Balance</th>");
out.write("</tr>");

// Here I have the code for getting the backend record and appending
it to the dynamically created table T1
while(rs.next())
{
out.write("<tr<td bgcolor=#ECF9FF
nowrap><input type=\"radio\" value=\"V\" checked name=\"Group\"><b>" +
rs.getString(1) + "</b></a></td>");
I am assuming that value=\"V\" is something for jsp to fill in the
value. But by your other calls I would say thats not likely. When
setting up a database I usually setup a primary Key that is auto
numbered. then I use that Key as an ID for the record. Now if you know
that the name is unique than you can use that. and have it like:
out.write("<tr>
<td bgcolor=#ECF9FF nowrap>
<input type=\"radio\" value=\"" +
rs.getString(1) + "\" name=\"id\" onChange=
\"javascript:document.radioform.submit();\"><b> " + rs.getString(1) +
"</b></a>
</td>");
out.write("<td>" + rs.getInt(2) + "</
td>");
out.write("<td>" + rs.getLong(3) +
"</td>");
out.write("<td>" + rs.getLong(4) +
"</td>");
out.write("<td>" + rs.getLong(5)+ "</
td></tr>");
}

out.write("</form>");

out.write("</table>");
}
rs.close();
pst.close();
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</div>
</body>
</html>

Any assistance from anyone is greatly appreciated !

Jan 30 '07 #6
On Jan 31, 2:36 am, "Adambrz" <Adam...@msn.comwrote:
Realize with my lack of JSP knowledge i am going to take a shot in the
dark here.
-----------------------------------------------------------------------
------------------------------------------------
On Jan 30, 3:59 pm, "eureka" <mseur...@rediffmail.comwrote:


On Jan 31, 1:01 am, "Adambrz" <Adam...@msn.comwrote:
Your killin' me! Just kidding. Doesn't sound to difficult.
It looks like you will create your table with jsp and the radio on
creation should the value should be declared. So I image it would look
something like this:
<body>
<form id="form1" name="form1" method="get" action="JSP1.jsp">
<table>
<%jsp to start loop to create radio button for each record%>
<tr><td>
<input type="radio" name="id" value="<%jsp code for ID%>"
onChange="javascript:document.form1.submit();" />
</td><td><%JSP to write Mr. Jack Brown</td>
</tr>
<%jsp for end of loop to go to next record%>
</table>
</form>
you should see that the form on submit to the same page. What will
happen is when radio button is selected i will auto submit the form to
the same page with the address being "JSP1.jsp?id=1234" or whatever
your id number is. I know php so i will just write out what I would do
for that to work.
Check to so if url param is set.
if set query database with id set to url param
fillin value of jsp1 form with those values.
Hope this helps and makes since feel free to ask any questions.
-----------------------------------------------------------------------
-----------------------------------------------------------------------
----------------------------------------------
Hi Adambrz
Thanks for your time and response,
A snapshot of my webpage is located here:-http://www.dynamicdrive.com/forums/attachment.php?
attachmentid=758&d=1170187911
It's a Jsp and on it I have a table (say T1) which is created
dynamically and contains all the backend-table's records as rows. I am
creating this dynamic table inside a <divon Jsp1 and using a Jsp-
scriptlet to get the backend data into the table. I have set a
vertical scrollbar on the <divsuch that user can see 4 rows of T1 at
a time. Each row in T1 has a radio button associated with it which is
used to select a particular row for modifying it. User can select a
single row at a time.
The requirement is that if I select the radio button on any row then
the cell-contents of that row should be populated in the corresponding
textfields of Jsp1.
For eg: if the user clicks the radio of the 3rd row then 'Student Name-
textfield' should show "Mr.Jonathan Brown"; 'Batch-ID-textfield'
should show "1" etc i.e. every textfield should be populated with the
corresponding cell value of the row.
I have grouped the radio-buttons and the group-name is "Group" but I
am totally clueless as to how to determine which row it is that has
its radio clicked and how to retrieve individual cell values of the
table and set them as text in the textfields of Jsp1?!
This is somewhat how my entire webpage(JSP) looks like in brief:-
<%@ page language = "JAVA" import = "java.sql.*" %>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title></title>
<style type=text/css>
# divStayTopLeft{
height:100px;
width:400px;
border:1px;
}
table.T1{
text-align:center;
font-weight:bold;
float:right;
width:450px;
}
. highlighted{
background-color:#ffffcc;
border:1px solid black;
}
</style>
<script language = "javascript">
// some clientside validation code
</script>
</head>
<body>
<form name = "Students">
<table>
<!-This is the main layout table and I have fixed my entire webpage in
to this table -->
</table>
</form>
<script>
document.write('<div id="divStayTopLeft"
style="position:absolute;overflow:scroll">')
</script>
<div id="divStayTopLeft">
<%
PreparedStatement pst ;
ResultSet rs = null ;

//create variables that are empty to fill into your form
String name = "";
int myint = null;
long mylong = null;

// check to see if url param is set. This is in php code so
you will have to adapt to jsp

if(isset($_GET['id']){
PreparedStatement pst2 ;
ResultSet rs2 = null ;
pst2 = con.prepareStatement("select * from Students WHERE
id=$_GET['id']");
rs2 = pst.executeQuery();}

//then set these variables equal to the field in the form
name = rs.getString(1) ;
//ect..
try
{
pst = con.prepareStatement("select * from
Students");
rs = pst.executeQuery();
if (rs != null)
{
out.write("<table class = \"T1\" id = \"TId\" border =
\"1\" cellspacing=0 cellpadding=2>");

out.write(" <form id="radioform" name="radioform"
method="get" action="jsp1.jsp">");
out.write("<tr>");
out.write("<th bgcolor=lightgrey>Candidate Name</th>");
out.write("<th bgcolor=lightgrey>Batch-ID</th>");
out.write("<th bgcolor=lightgrey>Reg Amt</th>");
out.write("<th bgcolor=lightgrey>Total Fees </th>");
out.write("<th bgcolor=lightgrey>Balance</th>");
out.write("</tr>");
// Here I have the code for getting the backend record and appending
it to the dynamically created table T1
while(rs.next())
{
out.write("<tr<td bgcolor=#ECF9FF
nowrap><input type=\"radio\" value=\"V\" checked name=\"Group\"><b>" +
rs.getString(1) + "</b></a></td>");

I am assuming that value=\"V\" is something for jsp to fill in the
value. But by your other calls I would say thats not likely. When
setting up a database I usually setup a primary Key that is auto
numbered. then I use that Key as an ID for the record. Now if you know
that the name is unique than you can use that. and have it like:
out.write("<tr>
<td bgcolor=#ECF9FF nowrap>
<input type=\"radio\" value=\"" +
rs.getString(1) + "\" name=\"id\" onChange=
\"javascript:document.radioform.submit();\"><b> " + rs.getString(1) +
"</b></a>
</td>");
out.write("<td>" + rs.getInt(2) + "</
td>");
out.write("<td>" + rs.getLong(3) +
"</td>");
out.write("<td>" + rs.getLong(4) +
"</td>");
out.write("<td>" + rs.getLong(5)+ "</
td></tr>");
}

out.write("</form>");
out.write("</table>");
}
rs.close();
pst.close();
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</div>
</body>
</html>
Any assistance from anyone is greatly appreciated !- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Thanks for all the help Adambrz , my code is up and running now!!
Cheers!

Feb 1 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: NoCopy na | last post by:
Using the following example: domiframetest.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
4
by: primary0 | last post by:
Hi, I have a page containing an external javascript which loads an image onto the webpage. How would it be possible to use javascript to read the filname (and the dimensions) of the loaded image...
22
by: Luke | last post by:
Elements with name attribute: form, input, textarea, a, frame, iframe, button, select, map, meta, applet, object, param, img (if you know more reply...) Methods of addresing html elements:...
17
by: Alex Blekhman | last post by:
Hello, I'm experienced Windows programmer, however, I'm quite novice in HTML technologies. Recently I was assigned a task to write small utility for internal use in our development team. I...
1
by: Mike | last post by:
I have an intranet page which has an iframe which links to a number of different possible .NET pages. In one of the embedded .NET pages (and soon to be others) we want to be able to capture...
1
by: jaktharkhan | last post by:
Hi, I really really need help in trying to figure out how can I do a CloneNode on an Iframe where the cloned IFRAME clones with all its contents?. Basically what I am doing is dynamically building...
3
by: tullyrob | last post by:
If you run the following simple line of code in Mozilla the webpage loads fine. However, a default page is displayed when opened in IE. --- <html> <iframe name=stbbox...
1
by: rissaofthesaiyajin | last post by:
I have a page with an iframe, and a Javascript function that I need to get the contents of the iframe - what I mean by that is, the text from the list.html file that's in the iframe. It's actually a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.