JavaScript Tutorials
- What is Javascript?
- What is BOM?
- What is DOM?
- Variable
- check variable value is empty
- JavaScript Output
- Functions
- Javascript Events
- Input Events
- onchange Event
- Javascript Output methods
- If else statement
- Arrays
- Pattern Validation
- Form Validation
- Inner Html Form Validation
- Inline Form Validation
- Checkbox Validation
- Inline Inner Html Form Validation
- Server side php Validation
- Validate a HTML Form with PHP
- window and window location
- Get Text Value
- Get hidden field value
- JavaScript & PHP
- Date Format
- get php value in javascript
- Redirect page & Autoredirect page
- Auto Refresh page & Div
- How to get select text value from Dropdown box
- How to clear browser history in javascript
- Checkbox Problems
- Select option problems
- Popup Contact Form
- Sidebar Contact Form
- How to use a multistep Form or Form wizard
- Auto Calculate Price
- print Application Form
- Auto Calculate GST in Javascript by select price
- Calculate GST by input value in text box Jquery
- Calculate Discount
- onClick Checkbox
- autofil form data click on checkbox
- Show subcategory list
- Show city list as per state
- Show district list as per country and state
- Show good morning good night wish
- image upload with preview image
- Print Div Content
- Show modal popup on page load
- filter table data usign javascript.
- Character Limit Validation.
- Validate File 5MB Upload
- Validate Special character
- More File Upload
- Call JavaScript Function After Page Load
- Drop Down First option Value Disabled --- Please Select ---
- How to Disable Submit Button After Form Submission
- How to disable browser back button using Jquery?
- How to Remove selected item from second & third dropdown list?
- Interview Questions of JavaScript.
Important Link
How to get select text from option box in JavaScript ?
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>How to get select box option text in JavaScript</title>
<script type="text/javascript">
function ShowOptionText() {
var selected_object = document.getElementById('typeofwork');
var selected_index = selected_object.selectedIndex;
alert(selected_object.options[selected_index].text);
}
</script>
</head>
<body>
<form name="frm" method="post">
<select name="typeofwork" id="typeofwork" onChange="ShowOptionText()">
<option value="0">Essay</option>
<option value="1">Dissertation</option>
<option value="2">Editing</option>
<option value="3">Proof Reading</option>
<option value="4">Admission Essays</option>
<option value="5">Article Writing</option>
<option value="6">Lab Report</option>
<option value="7">Web Content</option>
<option value="8">Math Problem</option>
<option value="11">Resume/CV Creation</option>
<option value="15">PowerPoint Presentation</option>
</select>
</form>
</body>
</html>
How to get the value of checkboxes selected in JavaScript
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>How to get the value of checkboxes in the order they are selected</title>
<script type="text/javascript">
arr = new Array();
function CheckboxOrder(elemId){
var chkBox = document.getElementById(elemId);
if(document.getElementById(elemId).checked) {
arr.push(elemId);
}
else {
for(var i = arr.length; i>=0; i--){
if(arr[i]==elemId){
arr.splice(i,1);
break;
}
}
}
for(var i = 0; i<=(arr.length-1); i++){
alert("checked value list ::"+arr[i]);
}
}
</script>
</head>
<body>
<input type="checkbox" id="A" onClick="CheckboxOrder('A')">A<br/>
<input type="checkbox" id="B" onClick="CheckboxOrder('B')">B<br/>
<input type="checkbox" id="C" onClick="CheckboxOrder('C')">C<br/>
<input type="checkbox" id="D" onClick="CheckboxOrder('D')">D<br/>
</body>
</html>