Call a javascript function to the page load event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmohan
    New Member
    • May 2008
    • 6

    #1

    Call a javascript function to the page load event

    Hi everyone,

    I am developing a website using asp.net with C#.

    And I developed a toolbar using javascript like google and yahoo toolbar which is placed in the browser separately.

    Toolbar has the toolbar id.

    I need to capture the toolbar id and save into the mysql database during the page load.

    So that, I put the javascript funcation called myFunc() in the Source file of the page to capture the toolbar id.

    I need to save the toolbar id into the mysql database and so I applied the coding to insert the toolbarid into the database.

    When I execute the coding, first of all, the page is loaded, then only the javascript is executed. Therefore, I am unable to get the toolbar id to the variable assigned in the page load.

    Please help me regarding this.

    How do I call the javascript function to the page load event.


    Thanks in Advance,

    J. Mohan.
  • EinToR
    New Member
    • May 2008
    • 20

    #2
    I don't beleive there's a way to do what you want the way your doing it unless you:

    1) Use ajax to pass the value from myFunc() to a seperate server-side page "page.aspx"

    2) "page.aspx"coul d take myFunc(), Session.Session ID, and the DateTime and insert it into a mysql table. In MSSQL there's a default value where you can put getdate(). I'm assuming mysql isn't that much different.

    //Here's where I'm not sure. I don't remember the Event order...
    3) In a page event, you can get the value you want by:

    //psudo code
    Code:
    select myFuncVal 
    from tableName
    where SessionID = Session.SessionID
    order by DataTimeField desc

    Comment

    Working...