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. Web Development
  3. ASP.NET
  4. Problem with JavaScript

Problem with JavaScript

Scheduled Pinned Locked Moved ASP.NET
javascriptdatabasehelp
5 Posts 4 Posters 0 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.
  • P Offline
    P Offline
    phani25485
    wrote on last edited by
    #1

    Hi I took a DropDownList and a button, i binded the DDl to a data source. EMP Table Emp_Name Emp_No John 12 Harry 13 Giri 14 The DDL displays the Emp names, Now when i click a button i want to show a alert which shows the Emp Number of the selected index in DDL Can you please tell me the code

    M S M 3 Replies Last reply
    0
    • P phani25485

      Hi I took a DropDownList and a button, i binded the DDl to a data source. EMP Table Emp_Name Emp_No John 12 Harry 13 Giri 14 The DDL displays the Emp names, Now when i click a button i want to show a alert which shows the Emp Number of the selected index in DDL Can you please tell me the code

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      phani25485 wrote:

      Can you please tell me the code

      NO, I wont give the code. But I will tell you what you should do. When you bind the datatable to the DDL, assign the text property as emp name and value property as emp number. Till now, we have done the server side part. Lets, come to the client side(Javascript) now. Write a function which will be called on the click of the button that returns you the selected value for the drop down list. That is it. Show it in the alert box. :) Give it a try. Write some code, and if you still stuck somewhere, comeback and someone would be happy to help you.:thumbsup:

      Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      P 1 Reply Last reply
      0
      • M Manas Bhardwaj

        phani25485 wrote:

        Can you please tell me the code

        NO, I wont give the code. But I will tell you what you should do. When you bind the datatable to the DDL, assign the text property as emp name and value property as emp number. Till now, we have done the server side part. Lets, come to the client side(Javascript) now. Write a function which will be called on the click of the button that returns you the selected value for the drop down list. That is it. Show it in the alert box. :) Give it a try. Write some code, and if you still stuck somewhere, comeback and someone would be happy to help you.:thumbsup:

        Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

        P Offline
        P Offline
        phani25485
        wrote on last edited by
        #3

        Actually its a cascading DDL when selecting the Dept name in the 1st DDL the second DDL displays the corresponding Emp name , upto this i have done it, Now i want emp no based on the second DDL in a alert box upon clicking a button. should i pass a sql command to a javascript function, if so i donno the syntax, I am new to javascript

        1 Reply Last reply
        0
        • P phani25485

          Hi I took a DropDownList and a button, i binded the DDl to a data source. EMP Table Emp_Name Emp_No John 12 Harry 13 Giri 14 The DDL displays the Emp names, Now when i click a button i want to show a alert which shows the Emp Number of the selected index in DDL Can you please tell me the code

          S Offline
          S Offline
          sashidhar
          wrote on last edited by
          #4

          Hi Try to bind the EmpNo to the ddl If u did it like below

          DDl.DataTextField = "Emp_Name";
          DDl.DataValueField = "Emp_No";

          now get the DataValueField From JavaScript

          If It Helps Click It as Answer

          1 Reply Last reply
          0
          • P phani25485

            Hi I took a DropDownList and a button, i binded the DDl to a data source. EMP Table Emp_Name Emp_No John 12 Harry 13 Giri 14 The DDL displays the Emp names, Now when i click a button i want to show a alert which shows the Emp Number of the selected index in DDL Can you please tell me the code

            M Offline
            M Offline
            Muhammad Mazhar
            wrote on last edited by
            #5

            in page load method put following code

            ddlEmp.Attributes.Add("onchange","showAlert(this)");

            then add following javascript on your page

            function showAlert(ele)
            {
            alert(ele.value);
            }

            Share your experience with others Check my Blog...

            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