Forum Sementara Putera.com

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


2 posters

    mcmana nak wat function tambah baris dalam table?

    avatar
    fifi85
    Ahli Baharu
    Ahli Baharu


    Number of posts : 40
    Registration date : 03/09/2009

    mcmana nak wat function tambah baris dalam table? Empty mcmana nak wat function tambah baris dalam table?

    Post by fifi85 Fri Dec 04, 2009 5:07 pm

    salam sume..

    saya dah wat function tambah baris dalam table saya.
    Dalam function tu wat dropdown list.
    Data diambil dari database.
    Masalahnya bila dah klik button tambah baris tu, utk row kedua dia tak kuar drop down list tu

    ni code saya.. saya wat dlm php dan javascript

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    <script language="javascript">
    function addRowToTable()
    {
    var tbl = document.getElementById('tblSample');
    var lastRow = tbl.rows.length;
    // if there's no header row in the table, then iteration = lastRow + 1
    var iteration = lastRow;
    var row = tbl.insertRow(lastRow);

    // left cell
    var cellLeft = row.insertCell(0);
    var textNode = document.createTextNode(iteration);
    cellLeft.appendChild(textNode);

    // select cell(yang ni tak tau cmane nak tukar)
    var cellRightSel = row.insertCell(1);
    var sel = document.createElement('select');
    sel.name = 'selRow' + iteration;
    sel.options[0] = new Option('text zero', 'value0');
    sel.options[1] = new Option('text one', 'value1');
    cellRightSel.appendChild(sel);
    }
    function keyPressTest(e, obj)
    {
    var validateChkb = document.getElementById('chkValidateOnKeyPress');
    if (validateChkb.checked) {
    var displayObj = document.getElementById('spanOutput');
    var key;
    if(window.event) {
    key = window.event.keyCode;
    }
    else if(e.which) {
    key = e.which;
    }
    var objId;
    if (obj != null) {
    objId = obj.id;
    } else {
    objId = this.id;
    }
    displayObj.innerHTML = objId + ' : ' + String.fromCharCode(key);
    }
    }
    function removeRowFromTable()
    {
    var tbl = document.getElementById('tblSample');
    var lastRow = tbl.rows.length;
    if (lastRow > 2) tbl.deleteRow(lastRow - 1);
    }
    function openInNewWindow(frm)
    {
    // open a blank window
    var aWindow = window.open('', 'TableAddRowNewWindow',
    'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');

    // set the target to the blank window
    frm.target = 'TableAddRowNewWindow';

    // submit
    frm.submit();
    }
    function validateRow(frm)
    {
    var chkb = document.getElementById('chkValidate');
    if (chkb.checked) {
    var tbl = document.getElementById('tblSample');
    var lastRow = tbl.rows.length - 1;
    var i;
    for (i=1; i<=lastRow; i++) {
    var aRow = document.getElementById('txtRow' + i);
    if (aRow.value.length <= 0) {
    alert('Row ' + i + ' is empty');
    return;
    }
    }
    }
    openInNewWindow(frm);
    }

    </script>

    <?php
    include('include/connect.php');
    include('include/database-control.func.php');
    ?>

    <body>
    <form action="tableaddrow_nw.html" method="post">
    <p>
    <input type="button" value="Add" onclick="addRowToTable();" />
    <input type="button" value="Remove" onclick="removeRowFromTable();" />

    </p>

    <table border="1" id="tblSample">
    <tr>
    <th colspan="3">Ahli-ahli</th>
    </tr>
    <tr>
    <td>1</td>

    <td>
    <select name="selRow0">
    <?php
    $query = @mysql_query("SELECT * FROM spb_panel");
    if (mysql_num_rows($query) > 0) {
    echo '<option value="">- Sila Pilih -</option>';
    while($row = mysql_fetch_array($query)) {
    echo "<option value='".$row['idPanel']."'>".$row['namaPanel']."</option><br />";
    }
    }
    ?>
    </select> </td>
    </tr>
    </table>
    </form>


    </body>
    </html>
    johnburn
    johnburn
    Moderators
    Moderators


    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    mcmana nak wat function tambah baris dalam table? Empty Re: mcmana nak wat function tambah baris dalam table?

    Post by johnburn Fri Dec 04, 2009 5:23 pm

    sy klik jd je. ape kuar pe2 error ke? pkai browser ape?
    avatar
    fifi85
    Ahli Baharu
    Ahli Baharu


    Number of posts : 40
    Registration date : 03/09/2009

    mcmana nak wat function tambah baris dalam table? Empty Re: mcmana nak wat function tambah baris dalam table?

    Post by fifi85 Fri Dec 04, 2009 5:47 pm

    oo..memangla jadik cik oi..
    utk row pertama tu data yg retrieve dari database tu dapat dikeluarkan
    cume bila dah klik tambah baris tu. row kedua saya tak reti nak retrieve dari dbase.
    tolong la btolkan javascript tu..
    taknak kuar 'text zero text one' tu.
    johnburn
    johnburn
    Moderators
    Moderators


    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    mcmana nak wat function tambah baris dalam table? Empty Re: mcmana nak wat function tambah baris dalam table?

    Post by johnburn Fri Dec 04, 2009 5:51 pm

    oo ok haha
    bleh nk tlg tp kne bg structure db yg dh ade skang la br mudah sy nk try.
    export je trus db awak
    avatar
    fifi85
    Ahli Baharu
    Ahli Baharu


    Number of posts : 40
    Registration date : 03/09/2009

    mcmana nak wat function tambah baris dalam table? Empty Re: mcmana nak wat function tambah baris dalam table?

    Post by fifi85 Fri Dec 04, 2009 5:54 pm

    CREATE TABLE `spb_panel` (
    `idPanel` int(2) unsigned zerofill NOT NULL auto_increment,
    `tarikhSidang` date default NULL,
    `namaPanel` varchar(80) default NULL,
    `kodBahagian` int(2) default NULL,
    `jawatan` varchar(15) default NULL,
    `tarikhCipta` datetime default NULL,
    `idPenggunaCipta` bigint(12) default NULL,
    `tarikhAkhirKemasini` datetime default NULL,
    `idPenggunaKemaskini` bigint(12) default NULL,
    `kodAktif` int(1) default NULL,
    PRIMARY KEY (`idPanel`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    johnburn
    johnburn
    Moderators
    Moderators


    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    mcmana nak wat function tambah baris dalam table? Empty Re: mcmana nak wat function tambah baris dalam table?

    Post by johnburn Fri Dec 04, 2009 6:10 pm

    ok rasenye dh pham ape yg awk nk buat. awk nk bile add tu, dropdown die kite bleh pilih ahli len kn? kl gitu awk xleh buat cmni sj. sbb javascript tu hanya akan create dlm bntuk html saje sdangkn awk perlu query ke db untuk dptkn list name tu. so awk kne pkai ajax la.
    avatar
    fifi85
    Ahli Baharu
    Ahli Baharu


    Number of posts : 40
    Registration date : 03/09/2009

    mcmana nak wat function tambah baris dalam table? Empty Re: mcmana nak wat function tambah baris dalam table?

    Post by fifi85 Fri Dec 04, 2009 6:11 pm

    cmane?
    johnburn
    johnburn
    Moderators
    Moderators


    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    mcmana nak wat function tambah baris dalam table? Empty Re: mcmana nak wat function tambah baris dalam table?

    Post by johnburn Fri Dec 04, 2009 6:16 pm

    err nt mlm ni insyaAllah sy tlg. sbb nk kne blk umah dlu ni haha
    avatar
    fifi85
    Ahli Baharu
    Ahli Baharu


    Number of posts : 40
    Registration date : 03/09/2009

    mcmana nak wat function tambah baris dalam table? Empty Re: mcmana nak wat function tambah baris dalam table?

    Post by fifi85 Mon Dec 07, 2009 5:55 pm

    cmane ni
    ade sape2 leh tlg x?
    ajax xmahir sgt la

    Sponsored content


    mcmana nak wat function tambah baris dalam table? Empty Re: mcmana nak wat function tambah baris dalam table?

    Post by Sponsored content


      Current date/time is Mon Nov 18, 2024 10:57 am