Markus: onload Event beim lader einer tabelle?

Hallo,

Ist es möglich beim laden einer Tabelle das event onload einzubauen?

Bsp.:
<table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListing" id="plistings" onload="javascript:pOpen('http://192.168.0.12/product_info.php?cPath=2044_2045_2046&products_id=128162')">

<tr target="unten" id="1" onclick="setStyle(this,id,'')"  >

Dies funktioniert nicht!!

Vielen Dank!!

  1. Hi,

    Dies funktioniert nicht!!

    table besitzt keinen eventhandler onload.

    Gruesse, Joachim

    --
    Am Ende wird alles gut.
    1. Hi,

      Dies funktioniert nicht!!
      table besitzt keinen eventhandler onload.

      Gruesse, Joachim

      Vielen Dank für deine schnelle Antwort.
      Habe ich mir fast gedacht.
      Gibt es überhaupt eine Möglichkeit, dieses Ereignis zu simulieren,
      d. h. das das Ereignis nur beim Laden der Tabelle ausgeführt wird?

      Bei mir ist das Problem etwas komplizierter gelagert, als es einfach im <body - Tag zu schreiben!

      Gruß

      Markus

      1. hi,

        Gibt es überhaupt eine Möglichkeit, dieses Ereignis zu simulieren,
        d. h. das das Ereignis nur beim Laden der Tabelle ausgeführt wird?

        Definiere bitte "das Ereignis" "Laden der Tabelle".

        Bei mir ist das Problem etwas komplizierter gelagert, als es einfach im <body - Tag zu schreiben!

        Dann erkläre es bitte detailierter.

        gruß,
        wahsaga

        --
        /voodoo.css:
        #GeorgeWBush { position:absolute; bottom:-6ft; }
        1. hi,

          Gibt es überhaupt eine Möglichkeit, dieses Ereignis zu simulieren,
          d. h. das das Ereignis nur beim Laden der Tabelle ausgeführt wird?

          Definiere bitte "das Ereignis" "Laden der Tabelle".

          Bei mir ist das Problem etwas komplizierter gelagert, als es einfach im <body - Tag zu schreiben!

          Dann erkläre es bitte detailierter.

          gruß,
          wahsaga

          beim Laden einer Tabelle soll eine Funktion aufgerufen werden, die eine URL übergeben bekommt. Diese URL wird aus der Tabelle gewonnen.
          Beispiel: Man hat eine Tabelle mit Produkte, und unten ein "iframe".
          Beim Laden (Aufrufen der Tabelle), soll der erste Datensatz gleich unten aufgerufen werden.

          Gruß

          Markus

          1. Nachtrag:
            Ich habe eine product-listing.php, diese erzeugt den Tabellen Inhalt,
            komplett als Array, und liest den href aus -->
            Die Daten werden an eine classe mit function weitergeleitet (boxes.php), dort erfolgt eine Aufbereitung der tabelle.
            Und die Index.php beherbergt die funktionen.

            Wie kann man nun in dem body-tag diese funktion aufrufen mit übergabe der url (aus der boxes.php)?

            Das ist doch ein großes Problem!

            Gruß

            Markus

            1. Ich habe eine product-listing.php, diese erzeugt den Tabellen Inhalt,
              komplett als Array, und liest den href aus -->

              Wie als Array? Als JS Array? Wer oder was liest href (ich nehme an du meinst window.location.href) aus und zu welchem Zweck?

              Die Daten werden an eine classe mit function weitergeleitet (boxes.php), dort erfolgt eine Aufbereitung der tabelle.

              'classe' what's that?
              'mit fucntion weitergeleitet' und sprichst in Rätseln.

              Und die Index.php beherbergt die funktionen.

              Welche index.php den auf einmal? Wo kommt die her?

              Wie kann man nun in dem body-tag diese funktion aufrufen mit übergabe der url (aus der boxes.php)?

              Jetzt haben wir noch eine Datei, von welchen deiner vielen Datei sprichst du?

              Das ist doch ein großes Problem!

              Ja, aber offensichtlich fällt es dir sehr schwer zu beschreiben was das Problem jetzt wirklich ist. Ich steig jetzt noch weniger durch als vorher.

              Struppi.

              1. Hy,

                Ich sag ja, etwas kompliziert: Generell PHP-Script mit HTML-Ausgabe! Shop mit vielen Erweiterungen OSCOMMERCE. Die index.php wird gestartet und gibt eine default Seite im HTML aus. Klicke ich nun auf eine kategorie wird über die index.php eine product-listing aufgerufen, diese ruft wiederrum eine php funktion, welche die HTML Tabelle ausgibt, und aus der Index.php die funktion aufruft.

                Doch etwas kompliziert.

                Bsp - Index.php:   } else { // default page ?>     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">       <tr>         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">           <tr>             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>             <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_default.gif', HEADING _TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

                </tr>         </table></td>       </tr>       <tr>         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>       </tr>       <tr>         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">           <tr>             <td class="main"><?php echo tep_customer_greeting(); ?></td>           </tr>           <tr>             <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>           </tr>           <tr>             <td class="main"><?php echo TEXT_MAIN; ?></td>           </tr>           <tr>             <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>           </tr>

                <td><?php //include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>           </tr>

                <tr> <!-- Angebote auf Startseite, wenn Bild verfuegbar ist -->                 <td><?php //include ( DIR_WS_MODULES . FILENAME_NEW_PRODUCTS );                     $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id,p .products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE _SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.lang uage_id = '" . (int)$languages_id . "' and s.status = '1' and p.products_image !='' order by s.specials_date_added DESC";                     $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);                     if (($specials_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION = = '3'))) {                     ?>

                Bsp Product-Listing.php       case 'PRODUCT_LIST_NAME': //        $lc_align = ''; //        if (isset($HTTP_GET_VARS['manufacturers_id'])) { //          $lc_text = '<a target="unten" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS[ 'manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . substr($listing['products_description'],0,28) . '</a

                ';

                //        } else { //          $lc_text = '&nbsp;<a target="unten" href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . ' &' : '') . 'products_id=' . $listing['products_id']) . '">' . substr($listing['products_description'],0,28) .   '</a>...&nbsp; '; //        } //        break;           $lc_align = '';           if (isset($HTTP_GET_VARS['manufacturers_id'])) { //              $lc_text = '&nbsp;<a target="unten" href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath  . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . substr($listing['products_description'],0,28) .   '</a>...&n bsp;';

                $lc_text = '<a style="cursor:default;"><font face="Arial" size="-2"><BIG><b>' . $listing['products_name'] . '</b

                </BIG></a><br></font>';

                $lc_text .= '<a style="cursor:default;"><font face="Arial" size="-3">' . $listing['products_description'] . '</a

                </font>';

                $href2[] .= tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $lis ting['products_id']) ;             } else {               $lc_text = '<a style="cursor:default;"><font face="Arial" size="-2"><BIG><b>' . $listing['products_name'] .   '< /b></BIG></font></a><br>';               $lc_text .= '<a style="cursor:default;"><font face="Arial" size="-3">' . $listing['products_description'] .   '< /font></a>';               $href2[] .= tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $lis ting['products_id']) ;               }         break;

                . . .     new productListingBox3($list_box_contents,$href2,$href3);

                } else {     $list_box_contents = array();

                $list_box_contents[0] = array('params' => 'class="productListing-odd"');     $list_box_contents[0][] = array('params' => 'class="productListing-data"',                                    'text' => TEXT_NO_PRODUCTS);

                new productListingBox3($list_box_contents,$href2,$href3);   }

                Bsp - boxex.php   class tableBox3 {     var $table_border3 = '0';     var $table_width3 = '100%';     var $table_cellspacing3 = '0';     var $table_cellpadding3 = '2';     var $table_parameters3 = '';     var $table_row_parameters3 = '';     var $table_data_parameters3 = '';     var $table_string3 = '';    //edit - noJS coolmenu     var $s = 0;

                // class constructor     function tableBox3($contents, $direct_output = false, $href2, $href3) {       $tableBox_string = '<table border="' . tep_output_string($this->table_border3) . '" width="' . tep_output_string($this-> table_width3) . '" cellspacing="' . tep_output_string($this->table_cellspacing3) . '" cellpadding="' . tep_output_string($this ->table_cellpadding3) . '"';       if (tep_not_null($this->table_parameters3)) $tableBox_string .= ' ' . $this->table_parameters3;       $tableBox_string .= ' onload="javascript:pOpen('' . addslashes($href3) . '')">' . "\n";

                for ($i=0, $n=sizeof($contents); $i<$n; $i++) {         if (isset($contents[$i]['form']) && tep_not_null($contents[$i]['form'])) $tableBox_string .= $contents[$i]['form'] . " \n";         $s= $s + 1;

                //        $tableBox_string .= '  <tr class="out" target="unten" id="' . $s . '" onclick="setStyle(this,id)" onmouseover={this. style.backgroundColor="#dfdf99"} onmouseout={this.style.backgroundColor="#f8f8f9"} ';         $tableBox_string .= '  <tr target="unten" id="' . $s . '" onclick="setStyle(this,id,'' . addslashes($href2[$s]) . '' )" '; //        $tableBox_string .= '  <tr id="' . $s . '" ';         if (tep_not_null($this->table_row_parameters3)) $tableBox_string .= ' ' . $this->table_row_parameters3;         if (isset($contents[$i]['params']) && tep_not_null($contents[$i]['params'])) $tableBox_string .= ' ' . $contents[$i][' params'];         $tableBox_string .= ' >' . "\n";

                if (isset($contents[$i][0]) && is_array($contents[$i][0])) {           for ($x=0, $n2=sizeof($contents[$i]); $x<$n2; $x++) {             if (isset($contents[$i][$x]['text']) && tep_not_null($contents[$i][$x]['text'])) { //              $tableBox_string .= '    <td onclick="pOpen('' . addslashes($href2[$s]) . '')"';               $tableBox_string .= '    <td';

                if (isset($contents[$i][$x]['align']) && tep_not_null($contents[$i][$x]['align'])) $tableBox_string .= ' align=" ' . tep_output_string($contents[$i][$x]['align']) . '"';               if (isset($contents[$i][$x]['params']) && tep_not_null($contents[$i][$x]['params'])) {                 $tableBox_string .= ' ' . $contents[$i][$x]['params'];               } elseif (tep_not_null($this->table_data_parameters)) {                 $tableBox_string .= ' ' . $this->table_data_parameters;               } /*            if ($x == "2"){               $tableBox_string .= ' width="33%" >';               }elseif ($x=="0"){               $tableBox_string .= ' width="25%" >';               }elseif ($x=="1"){               $tableBox_string .= ' width="31%" >';               }elseif ($x=="3"){               $tableBox_string .= ' width="8%" >';               }               elseif ($x=="4"){               $tableBox_string .= ' width="3%" >';               } */               $tableBox_string .= ' >';

                if (isset($contents[$i][$x]['form']) && tep_not_null($contents[$i][$x]['form'])) $tableBox_string .= $contents[$ i][$x]['form'];               $tableBox_string .= $contents[$i][$x]['text'];               if (isset($contents[$i][$x]['form']) && tep_not_null($contents[$i][$x]['form'])) $tableBox_string .= '</form>';               $tableBox_string .= '</td>' . "\n";             }           }         } else {           $tableBox_string .= '    <td';           if (isset($contents[$i]['align']) && tep_not_null($contents[$i]['align'])) $tableBox_string .= ' align="' . tep_outp ut_string($contents[$i]['align']) . '"';           if (isset($contents[$i]['params']) && tep_not_null($contents[$i]['params'])) {             $tableBox_string .= ' ' . $contents[$i]['params'];           } elseif (tep_not_null($this->table_data_parameters)) {             $tableBox_string .= ' ' . $this->table_data_parameters;           }           $tableBox_string .= '>' . $contents[$i]['text'] . '</td>' . "\n";         }

                $tableBox_string .= '  </tr>' . "\n";         if (isset($contents[$i]['form']) && tep_not_null($contents[$i]['form'])) $tableBox_string .= '</form>' . "\n";       }

                $tableBox_string .= '</table>' . "\n";

                if ($direct_output == true) echo $tableBox_string;           $this->table_string3 = $tableBox_string;      //edit - noJS coolmenu

                return $tableBox_string;     }   } . . .    class productListingBox3 extends tableBox3 {     function productListingBox3($contents,$href2,$href3) {       $this->table_parameters3 = 'class="productListing" id="plistings"';       $this->tableBox3($contents, true,$href2,$href3);     }

                Etwas komplex!, Oder!

                1. Etwas komplex!, Oder!

                  sorry, ja!

                  Das liesse sich wahrscheinlich leichter live beurteilen

                  Struppi.

          2. beim Laden einer Tabelle soll eine Funktion aufgerufen werden, die eine URL übergeben bekommt. Diese URL wird aus der Tabelle gewonnen.

            Du kannst evtl. einfach das skript unterhalb des schliessenden Table Tags ausführen.

            Beispiel: Man hat eine Tabelle mit Produkte, und unten ein "iframe".
            Beim Laden (Aufrufen der Tabelle), soll der erste Datensatz gleich unten aufgerufen werden.

            Es gibt kein beim laden einer Tabelle.
            Grundsätzlich gibt es nur den onload Handler für window Elemente (und undokumentiert für Image ).

            Das Problem bei meinem Vorschlag dürfte sein, dass u.U. der iFrame noch nicht vorhanden ist.

            Struppi.

          3. hi,

            bitte zitiere sinnvoll, und vermeide Fullquotes.

            Und das sich jemand mit der Masse an Code, mit der du uns zuschei^H^Hütten möchtest, beschäftigen mag, nimmst du doch hoffentlich nicht ernsthaft an?

            beim Laden einer Tabelle soll eine Funktion aufgerufen werden, die eine URL übergeben bekommt. Diese URL wird aus der Tabelle gewonnen.
            Beispiel: Man hat eine Tabelle mit Produkte, und unten ein "iframe".
            Beim Laden (Aufrufen der Tabelle), soll der erste Datensatz gleich unten aufgerufen werden.

            Wenn du die Tabelle schon serverseitig generierst, dann hast du dort wohl auch diesen URL zur Verfügung.

            Also gebe ihn gleich als src des Iframes an, sofern dieser sich im gleichen, gerade erzeugten Dokument befindet - oder erzeuge den Javascript-Code, der die Adresse des Iframes ändert, dynamisch und so, dass er nach dem Laden ausgeführt wird (body onload, oder irgendwo als <script> am Ende des Dokumentes).

            gruß,
            wahsaga

            --
            /voodoo.css:
            #GeorgeWBush { position:absolute; bottom:-6ft; }