#1
  1. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Oct 2004
    Location
    India
    Posts
    3
    Rep Power
    0

    Angry can't create dynamic table throught Javascript


    Hi there,
    I am trying to create an html page in which there will be a dynamic table there will be four text boxes for the four columns of the tables.
    In addition there will be four buttons to ADD, MODIFY, DELETE the records from the table and and a FINISH button to submit the form
    All the information will be be stored in a array or a similar data type though I have got some coding based on Iframes but that is good only to add the data not for modify or delete.




    Can anybody help me out in this

    Any help will be appreciated
  2. #2
  3. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Sep 2004
    Posts
    13
    Rep Power
    0
    Originally Posted by amit_chauhan79
    Hi there,
    I am trying to create an html page in which there will be a dynamic table there will be four text boxes for the four columns of the tables.
    In addition there will be four buttons to ADD, MODIFY, DELETE the records from the table and and a FINISH button to submit the form
    All the information will be be stored in a array or a similar data type though I have got some coding based on Iframes but that is good only to add the data not for modify or delete.




    Can anybody help me out in this

    Any help will be appreciated
    Well I'm not sure what kind of help you are looking for. But maybe this can get you started. Mind you most of my hardcare javascripting has been for internal rapid development IE apps.

    Have an input form that will take in your parameters.
    Create a DIV tag give it an ID.
    Now, save any input data into an array, using a delimeter between rows..
    Using innerHTML on the DIV you can build the dynamic table everytime the user hits an action such as delete, edit, insert.

    Sorry no time for giving you code, but do some searchs on DIV and innerHTML and you should find some good stuff.
  4. #3
  5. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    May 2005
    Location
    Johannesburg, South Africa
    Posts
    9
    Rep Power
    0

    Db's and JavaScript


    Hey amit_chauhan79, JavaScript is a pretty handy client side language, but one thing you should remember about it, is that it is CLIENT side. This means that the users browser might support and enable it or not. Unlike ASP, for example, the code will not always be consistent and display the info like you want it to due to the client side environment and settings.

    What you want, however, is possible is JavaScript so im going to include a code snippet to get you started. This code uses JavaScript and a Database to contain the posted information:

    Code:
    <SCRIPT LANGUAGE=JAVASCRIPT>
    
    var conn = new ActiveXObject("ADODB.Connection") ;
    var connectionstring = "Provider=SQLOLEDB;Server=localhost;User ID=yourid;Password=yourpassword;Database=yourdbname;"
    
    conn.Open(connectionstring)
    var rs = new ActiveXObject("ADODB.Recordset")
    
    
    Remember to select your own table Code:
     
    rs.Open("SELECT * FROM yourtable", conn)
    while(!rs.eof) { alert(rs(0)); rs.movenext } rs.close conn.close </SCRIPT>
    In your while loop, write a for loop to go through the whole db and paste all that info into a table. if you want to delete a specific value, then you can do that by changing your sql string to a delete query. Same with editing using an update query. Write specific functions for editing and deleting and use the onClick event in your html to fire the respected method. e.g.:

    Code:
    <SCRIPT LANGUAGE=JAVASCRIPT>
    function delete(name)
    {
        var conn = new ActiveXObject("ADODB.Connection") ;
        var connectionstring = "Provider=SQLOLEDB;Server=localhost;User ID=yourid;Password=yourpassword;Database=yourdbname;"
    
        conn.Open(connectionstring)
        var rs = new ActiveXObject("ADODB.Recordset")
        
        rs.Open("DELETE * FROM yourtable WHERE User_Name LIKE '" + name + "'", conn)  	  
        
        rs.close
        conn.close 
    }
    </SCRIPT>
    I hope that helps you out. The rest im not going to include as it is just html coding creating the table and buttons.
    Last edited by SEO_Jonty; Aug 29th, 2005 at 06:56 AM.

Similar Threads

  1. Google - dynamic link with javascript menu ??
    By Turbo123 in forum Google Optimization
    Replies: 3
    Last Post: Sep 3rd, 2004, 06:53 AM
  2. Splash Pages, Cookies, & JavaScript.. Oh My!
    By TheFesta in forum Search Engine Optimization
    Replies: 1
    Last Post: Mar 22nd, 2004, 08:34 PM
  3. Replies: 19
    Last Post: Nov 25th, 2003, 08:15 AM

IMN logo majestic logo threadwatch logo seochat tools logo