C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to select value in dropdownlist using java script


Posted Date: 14 Jul 2008      Total Responses: 2

Posted By: sachin       Member Level: Silver     Points: 1



I'm having appln to select value from drop downlist using java script without post back
and don't use ajax
in Asp.net & C#






Responses

Author: sachin    14 Jul 2008Member Level: SilverRating:     Points: 6

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="jsddlselection.aspx.cs" Inherits="jsddlselection" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

<script language="javascript" type="text/javascript">

function displayfun()

{

var name = "tr_" + document.getElementById('ddlName').value;

var trname = document.getElementById(name);

trname.style.display = 'block';

return true;

}



function fnTest()

{

var tblId= document.getElementById ('tblId').innerText;

var len= document.getElementById('ddlName').length;

var ddlitems=document.getElementById('ddlName').innerText;

var splititmes=ddlitems;

var mysplit= splititmes.split(" ");

//alert(mysplit[1]+" "+mysplit[2]+" "+mysplit[3]+" "+mysplit[4]);

var name = "tr_" + document.getElementById('ddlName').value;

var trname = document.getElementById(name);

for(var i=1; i<len+1;i++)

{

var aftersplit = mysplit[i];

// var mytablerow = tablerow.split(aftersplit);

aftersplit="tr_"+ aftersplit;

for (var j=1;j<len+1;j++)

{

var mysplit1 = mysplit[j];

// var mytablerow = tablerow.split(aftersplit);

mysplit1="tr_"+ mysplit1;

var AllRows = document.getElementById (mysplit1);

AllRows.style.display="none";

// return false

}

if(aftersplit== name)

{

// trname.style.display = 'block';

displayfun();

return true;

}

}

// return false;

}

</script>

</head>

<body >

<form id="form1" runat="server" >

<div id="div_id1" runat="server" >

<asp:DropDownList ID="ddlName" runat="server" >

</asp:DropDownList></div>

<div id="div_id" runat ="server" ></div>

<div id="divi1" runat ="server" ></div>

</form>

</body>

</html>






Author: mahalakshmi    14 Jul 2008Member Level: GoldRating:     Points: 3

hi,

server side:
<asp:drodownlist id="df" onchange="dsl();" runat="server"/>

javascript:

function dsl()
{
var ddlv=document.getElementById("df").value;
alert(ddlv);
}

try this.



Post Reply
You must Sign In to post a response.
Next : How to swap two variable values without using the third variable in asp.net 2.0
Previous : Textbox Problem
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use