JQuery gets the value of of in the selected radio check box and drop down box

  • 2020-03-30 02:04:21
  • OfStack

Examples are as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript" src="jquery-1.3.min.js"></script>
<script type="text/javascript">
function aa(){
//Gets the value of the radio button
var a = $("input[name='sex'][checked]").val();
function bb(){
//Returns true if selected, false otherwise
var c = $("#a").attr("checked");
//Gets the value of a single check box
var d = $("input[name='checkName'][checked]").val();
//Gets the value of multiple check boxes
function checkWeek(){
//var $param = {};
//    var key = $(this).attr("name");
//    if(!$param[key])
//        $param[key] = [];
//Get the value value
var value = $("##mPrefType option:selected").val();
//Get the required value
var name = $("##mPrefType option:selected").text();
Number:<input type = "text" value ="" name ="num1"/><br>
Number:<input type = "text" value ="" name = "num2"/><br>
<input type = "radio" value = "a"  name = "ss" />a
<input type = "radio" value = "b"  name = "ss" />b
<input type = "radio" value = "c"  name = "ss"/>c
<input type = "radio" value = "d"  name = "ss" >d<br>
<input type = "submit"  value = " submit "/> <br>
<input type="radio" value=" male " name="sex" id="1" onclick="aa()"/> male 
<input type="radio" value=" female " name="sex" id="0" onclick="aa()"/> female <br>
<input type="button" value=" The gender of your choice " onclick="aa()"/><br>
<input type="checkbox" name="checkName" value="aa" id="a"/>aa
<input type="checkbox" name="checkName" value="bb" id="b"/>bb
<input type="checkbox" name="checkName" value="cc"/>cc
<input type="checkbox" name="checkName" value="dd"/>dd<br>
<input type="button" value=" The value you selected is " onclick="bb()"/>
<li> Please choose ze </li>
<select id="mPrefType" name="mPrefType" class="inputS" onchange="checkWeek()">
<option value=0> Please select a :</option>
<option value=1> Monday </option>
<option value=2> Tuesday </option>
<option value=3> Wednesday </option>
<option value=4> Thursday </option>
<option value=5> Friday </option>
<option value=6> Saturday </option>
<option value=7> Sunday </option>

Related articles: