Forum Moderators: open

Message Too Old, No Replies

get info from Iframe

putting information from a table into a parent <input>

         

mcibor

7:33 pm on Dec 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In a iframe I've got information from SQL put into a table. eg:
no, name, cost, profit
1, foo, $50000, $50050
2, fo1, $10023, $10024
3, fo2, $12000, $12600

Rows are clickable <tr onclick="...">

How do I put information from whole row that is clicked into a parent form inputs
<form><input type="text" name="no" id="no">?

What do I have to place in onclick in a <tr> and what in parent window?

Thanks for any advice.
Michal Cibor

birdbrain

4:31 pm on Dec 18, 2004 (gmt 0)



Hi there mcibor,

this may give you a few ideas to play with...

iframe.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>iframe</title>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<style type="text/css">
/*<![CDATA[*/
body {
background:#aaa;
}
#ifrm {
width:512px;
margin:20px auto;;
}
#ifrm iframe {
width:512px;
height:100px;
}
#inpts {
width:480px;
margin:20px auto;
}
#inpts input {
width:150px;
font-size:14px;
text-align:center;

}
/*//]]>*/
</style>

<script type="text/javascript">
//<![CDATA[
//]]>
</script>

</head>
<body>

<div id="ifrm">
<iframe src="table.html" scrolling="no"></iframe>
</div>

<form action="">
<div id="inpts">
<input type="text"/>
<input type="text"/>
<input type="text"/>
</div>
</form>

</body>
</html>


table.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>three cell table</title>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<style type="text/css">
/*<![CDATA[*/
body {
margin:20px;
background:#ccc;
}
#tble {
border:solid 1px #000;
background:#fff;
}
#tble td {
width:150px;
height:50px;
border:solid 1px #000;
font-size:12px;
text-align:center;
cursor:pointer;
}
/*//]]>*/
</style>

<script type="text/javascript">
//<![CDATA[
function doStuff(num,el) {
parent.document.forms[0][num].value=el.innerHTML;
}
//]]>
</script>

</head>
<body>

<table id="tble"><tr>
<td onclick="doStuff(0,this)">cell one information</td>
<td onclick="doStuff(1,this)">cell two information</td>
<td onclick="doStuff(2,this)">cell three information</td>
</tr></table>

</body>
</html>

birdbrain

mcibor

7:29 pm on Dec 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Birdbrain!

I don't understand how does it work, but it works! GREAT!

Could you please only tell me what does <![CDATA[ ... ]]> mean? Is it some xml declaration? But in css declaration? Why?

Is there anyone out there?

Merry Christmas!