Problem with JavaScript
-
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
-
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
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.
-
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.
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
-
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
-
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
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...