I'm trying to achieve as the title suggests. Currently I can display the contents of a <div>
using:
document.write(<table><tr>);
...
document.write(<td onclick=window.location.href='#popup' ... > + name + </td>);
With the <div>
defined as: (where I'm trying to use data-name
)
<div id=popup data-name=name class=dialog>
<a href=#close><img src=... alt=... width=166 height=104 align=left /></a>
<p>
Hello (dynamic name here)!
</p>
</div>
I have tried instead calling:
document.write(<td onclick=popup( + name + ) class=programme> + name + </td>);
function popup(movieName)
{
var pop = document.getElementById(popup);
pop.setAttribute(data-movie, movieName);
document.location.href = #popup;
};
but I no longer see the popup this way.
I would eventually want to popup to be a modal dialogue window which will display on top of the table. Currently as it's defined above the table it just pushes the table down when displayed.
Edit: Thanks for the fantasic help. Both @carlosHT and @TimeDead. Both solutions work and both taught me a lot. I've gone for carlosHT's solution as it's a smaller implementation. The only addition I had to add was:
.ui-dialog
{
clear: both;
}
This stops the dialog window from having a very tall titlebar.