First off, Hi all. I've recently moved to PHP after a few months on C#, and I feel like I'm right back in year 1 at school. I'm working my way through a few tutes, and one of them has a (kind of) 'now it's your turn' at the end...
On the whole I've been doing OK, but one of the exercises wants me to change an 'open browser' window command to a simple link-to-page. I understand the principle but the syntax is killing me.
I haven't just come here to cheat, I've spent hours looking at various docs and guides, but I can't seem to crack this basic problem.
The current code is:
I'd ideally like to create the link using 'onclick' rather than use a standard link, can anyone help? Please?
$eventwin = 'onclick="window.open(\'index.php?option=someurl&id='.$item->id.'\', \'win2\', \'width=800,height=400,top=100,left=100,scrollbars=1\')" ';
Separate your js from your html with a function call. Let the function set all the parms and execute the window.open call. Much easier to write and to understand afterwards. Just put the onclick clause in your html tag, ie:
echo "<input type='button' onclick='openWindow(\"$id\")' value='xxxxx'>";
Ideally you can do this:
or the different approach is given below,you can try it out and see if it help you to solve your problem:
Hope this helps.