C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » JavaScript »

How to show a value of dropdow in javscript


Posted Date: 02 Nov 2009      Posted By: kumar      Member Level: Gold     Points: 1   Responses: 2



<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>

<script type="text/javascript">
$(document).ready(function(){
$("#theSelect").toggle(0);
$("#activate").click(activate)
})

function activate(e) {
$("#theSelect").toggle((e.target.checked));

if (!e.target.checked) { // reset selection
$("#theSelect option[value='--Select--']").attr('selected', 'selected');
}
}
</script>
<table>
<tr>
<td>
<select id="theSelect">
<option value="--Select--">--Select--</option>
<option value="foo">foo</option>
<option value="bar">bar</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="activate" /> Activate
</td>
</tr>
</table>
the above is code during the insert mode
i have one page(insert-upadte.aspx) both for insert and upadte mode .


but in update mode(in .cs )
i will be checking
if(check.text!=)
{
check.checked= true;
dropdown.seletedValue= "india"
}
when this condition is staisfied i need to check the check box and show the selected value of the drop down what i have in .cs page

intially in my javscript i will be checking the dropdown value if it has value means then show that value .if not showing the default value i.e(-select-) for the drop down

if any one can help me out how to solve this issue . would be great

thank you






Responses

Author: satya    02 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Hi,

It may help tou.


if(document.getElementById("ddlLocation").options[document.getElementById("ddlLocation").selectedIndex].value=="New Location")
{
if(document.getElementById("txtLocation").value=="")
{
alert('Please Enter Location');
document.getElementById("txtLocation").focus();
return false;
}
}



Author: Shawpnendu bikash maloroy    04 Nov 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

You can read the following link. Hope it will help you:

http://shawpnendu.blogspot.com/2009/08/javascript-how-to-get-selectedtext-from.html



Post Reply
You must Sign In to post a response.
Next : Change Image name dynamically
Previous : Interview question ebooks
Return to Discussion Forum
Post New Message
Category: JavaScript

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use