Click to See Complete Forum and Search --> : How do I create a popup box from php link?


porsche21
08-30-2007, 11:53 AM
I want to create a popup box when i click on the link how do I do this and is it possible?



if ($pview != 1)
{
echo "<table><tr><td width=\"100%\">";


$create_by = $GLOBALS['phpgw_info']['user']['account_id'];

$sql = "select name, id, create_by, description from trucks_entry where create_by=$create_by order by name";
$GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
while ($GLOBALS['phpgw']->db->next_record())
{
/*echo "<img src=" . $GLOBALS['phpgw_info']['server']['app_images']. "/return_img.jpg align=absmiddle></a>";*/

//Show all owners trucks
if ($GLOBALS['phpgw']->db->f('create_by') == $create_by)
{
echo "<u>$vocab[yourtruck]</u><br>";
}
echo "<a href=\"edit_entry.php?year=$year&month=$month&day=$day&id=" . $GLOBALS['phpgw']->db->f(
'id'). "\" >";

if ($GLOBALS['phpgw']->db->f('create_by') == $create_by)
{

echo "<font color=\"blue\">" . htmlspecialchars(
$GLOBALS['phpgw']->db->f(
'name')). "
</font></a> <br>\n";

/* var_dump($id);*/
}
else
{
echo htmlspecialchars($GLOBALS['phpgw']->db->f('name')). "</a><br>\n";
}
}

blis102
08-30-2007, 12:31 PM
What type of pop-up box? A "Confirm" box, an "Alert" box, or a new window popup?

porsche21
08-30-2007, 12:34 PM
A new popup window that contains a simple form that when i submit will populate my database.:)

blis102
08-30-2007, 01:30 PM
Here is a simple script I wrote that will do what you are looking for:

The Javascript (include in external file)
function getElementsByClass(className) {
var all = document.all ? document.all : document.getElementsByTagName('*');
var elements = new Array();
for (var e = 0; e < all.length; e++) {
if (all[e].className == className)
elements[elements.length] = all[e];
}
return elements;
}

function popup(elmClass,width,height) {
var popupElms = getElementsByClass(elmClass);
for (var i = 0; i < popupElms.length; i++) {
var popupElm = popupElms[i];
popupElm.onclick = function() {
var popupElmURL = this.getAttribute('href');
var popupElmTitle = this.getAttribute('title');
if (width && height) {
var windowSize = 'width=' + width + ',' + 'height=' + height;
}
var popup = window.open(popupElmURL,popupElmTitle,windowSize);
return false;
}
}
}

window.onload = function() {
popup('popup',500,300);
}

The HTML
<a href="http://www.google.com" title="Google Window" class="popup">Go to Google</a>
<a href="http://www.yahoo.com" title="Yahoo Window" class="popup">Go to Yahoo</a>
<a href="http://www.msn.com" title="MSN Window" class="popup">Go to MSN</a>

All you need to do is declare the class,width, and height of your popup in the window.onload function:

window.onload = function() {
popup('popup',500,300);
}

Hope that helps