Tuesday, October 18, 2011

how do get selected value from html dropdown in javascript

document.getElementById('yourSelectBoxId').options[document.getElementById('yourSelectBoxId').selectedIndex].value

how to enable textbox enabled false in mvc

  <%= Html.TextBoxFor(m => m.PopupImportEmailId, new { @class = "txtSearch", disabled = "true", @onkeypress = "return OnEnter(event);" })%>

Monday, October 17, 2011

how to open popup by javascript

<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
 newwindow=window.open(url,'name','height=200,width=150');
 if (window.focus) {newwindow.focus()}
 return false;
}

// -->
</script>

how to find entry key is pressed by javascript function

<script type="text/javascript">
function displayunicode(e){
var unicode=e.keyCode? e.keyCode : e.charCode
alert(unicode)
}
</script>
<form>
<input type="text" size="2" maxlength="1" onkeyup="displayunicode(event); this.select()" />
</form>