Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. updating javascript value to database

updating javascript value to database

Scheduled Pinned Locked Moved C#
javascriptdatabasehelpannouncement
5 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dsaikrishna
    wrote on last edited by
    #1

    Dear all, I am facing a problem with a javascript function i had with me javascript for country generation and also on change of country state generation w.r.t of country but i want to fetch the selected value of country and state and to update in the database using sqlserver.

    sai krishna

    G M 2 Replies Last reply
    0
    • D dsaikrishna

      Dear all, I am facing a problem with a javascript function i had with me javascript for country generation and also on change of country state generation w.r.t of country but i want to fetch the selected value of country and state and to update in the database using sqlserver.

      sai krishna

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      If you divide your text into sentences, it might be possible to understand what you are trying to say. As I gather it, you want to do something (update? insert?) with an MS SQL Server database from Javascript? You can't do that. Well, it's possible, but that would mean that you expose your database login to everyone. You have to post the information to the server, where you do the database work.

      --- single minded; short sighted; long gone;

      D 1 Reply Last reply
      0
      • G Guffa

        If you divide your text into sentences, it might be possible to understand what you are trying to say. As I gather it, you want to do something (update? insert?) with an MS SQL Server database from Javascript? You can't do that. Well, it's possible, but that would mean that you expose your database login to everyone. You have to post the information to the server, where you do the database work.

        --- single minded; short sighted; long gone;

        D Offline
        D Offline
        dsaikrishna
        wrote on last edited by
        #3

        Thanks guffa, for ur prompt msg, but i have a javascript code written for country selection and this is the aspx statement i am writing to call javascript but in the javascript onchange event is to give the corresponding state of the country another javascript so what i have to do to get the selected value of the country thanks once again

        sai krishna

        J 1 Reply Last reply
        0
        • D dsaikrishna

          Thanks guffa, for ur prompt msg, but i have a javascript code written for country selection and this is the aspx statement i am writing to call javascript but in the javascript onchange event is to give the corresponding state of the country another javascript so what i have to do to get the selected value of the country thanks once again

          sai krishna

          J Offline
          J Offline
          Justin Jones 0
          wrote on last edited by
          #4

          I'm not entirely sure I understand your problem either, but what it sounds like you want to do is populate a state combo box based on the users selection in a country combo box. You don't want connection strings in your web page unless your resume is up to date. I think you're going to have to look into an ajax solution unless you want to do a full postback each time the user changes their selection.

          J Make the logo bigger

          1 Reply Last reply
          0
          • D dsaikrishna

            Dear all, I am facing a problem with a javascript function i had with me javascript for country generation and also on change of country state generation w.r.t of country but i want to fetch the selected value of country and state and to update in the database using sqlserver.

            sai krishna

            M Offline
            M Offline
            Michael Sync
            wrote on last edited by
            #5

            dsaikrishna wrote:

            I am facing a problem with a javascript function i had with me javascript for country generation and also on change of country state generation w.r.t of country but i want to fetch the selected value of country and state and to update in the database using sqlserver.

            Okay. #1. Declare one variable in code-behind to hold the status. string selectedCountry = string.Empty; #2. Add one server-side hidden field (a HTML hidden field with RunAt="Server") in your page. <input id="Hidden1" type="hidden" runat="server" onserverchange="Hidden1_ServerChange"/> #3. Add change event of this hidden field protected void Hidden1_ServerChange(object sender, EventArgs e) { } #4. In onchange event of Country list, you can set the value to this hidden field.. For example, if you select "Singapore" from combobox, set this to hidden field by using javascript. var objHdf = document.getElementById('Hidden1'); objHdf.value = document.getElementById('cboCountry').selectedtext; #5. As soon as the value of hidden field get changed, the server side event of hidden field will be invoked. So, get the value from hidden and set it to string that we declare earlier.. protected void Hidden1_ServerChange(object sender, EventArgs e) { selectedCountry = Hidden1.Value; } Okay. now, you get the value so, you can insert it to SQL database.. Hope it helps.. :)

            Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups