SoFunction
Updated on 2025-04-10

Some usage summary of javascript

The following usage requires adding the attribute onclick to JSP. Taking the selection all as an example, onclick="javascript:allselect()"//javascript can be omitted
Or use function allselect() ("allselectbox").onclick = function();
Select all:
fuction allselect(){
var form = [0];
var state = ;
var length = ;
if(length){
for(var i=0;i<length;i++){
[i].checked=state;
}
}else = state;
}
Another way to write all:
function allSelect(){
var items = ("usernames");
var state = ("allselectbox")[0].checked;
if(){
for(var i = 0; i < ; i++){
items[i].checked = state;
}
}else{
= state;
}
}
Single choice:
fuction selectitem(){
var form = [0];
var length = ;
if(length){
for(var i=0;i<length;i++){
if([i].checked) return true;
}
}else return ;
}
Go to another page:
function topage(page){
var form = [0]
= page;
;
}
Take the value of the radio box Radio:
function getradiovalue(objradio){
var result = "";
try{
if(typeof()=="undefined"){
for(var i=0;i<;i++){
if(objradio[i].checked){
return objradio[i].value;
}
}
}else{
if() result = ;
}
}catch(e){result = "";}
return result;
}
Email Verification:
function isValidEmail(inEmail){
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return (inEmail);
}
Check the cell phone format:
function validateMobile(){
var form = [0];
if(!=""){
var num = /^1[35]\d{9}$/
if(!()){
alert("The consignee's mobile phone number format is incorrect");
return false;
}
alert("correct");
}
}
to be continued........