jquery Processing page

Source: Internet
Author: User

function Save (flag) {
var groupId = $ (' input[name= "groupId"] "). Val (); Group GroupID
About the definition of creation time
var date = new Date ();
var year = Date.getfullyear ();
var month = Date.getmonth () + 1;
var dt = date.getdate ();
var today = year + "-" + month + "-" + dt;
var flights = $ (' input[name= "flights"] "). Val (); Domestic round-trip ticket costs
var visa = $ (' input[name= ' visa '). Val (); Domestic visa Fees
var airport = $ (' input[name= ' airport ') '. Val (); Domestic Airport charges
var domestic = $ (' input[name= "domestic"] '). Val ();//Domestic other costs

var data = []; Data collection that needs to be saved
var countrynames = $ ("input[name^= ' CountryName ')");
Countrynames.each (function (i) {//i is a national flag
var zsfrstotal = 0,hsfrstotal = 0,gzfrstotal = 0; Total number of people added for each type
var countryname = this;
var Fahterid = $ ("input[name^= ' Fatherid" +i+ "']"); Primary table primary Key
var traffice = $ ("input[name^= ' Traffic" +i+ "']"); Get all the transportation expenses for a country
var overseas = $ ("input[name^= ' Overseas" +i+ "']"); Get all the other fees for a country
var currency = $ ("input[name^= ' Currency" +i+ "']"); Get all currency fees for a country
var exchangerate = $ ("input[name^= ' exchangerate" +i+ "']"); Get all the exchange rate fees for a country
var countrys = {
' ID ': Fahterid.val (),
' Flights ': flights,
' Visa ': Visa,
' Airport ': airport,
' Domestic ':d omestic,
' Country ': Countryname.value,
' Traffic ': Traffice.val (),
' Overseas ': Overseas.val (),
' Currency ': Currency.val (),
' ExchangeRate ': Exchangerate.val (),
' Flag ': Flag,
' Credate ': Today,
' GroupId ': groupId,
' Accommodation ': ',
' Meals ': ',
' Miscellaneous ': ',
Fydata: []
}
var ZSF = $ ("input[name^= ' accommodation" +i+ "']"); Get all accommodation fees in a country
var ZSF = $ ("tr[id^= ' zsf" +i+ "']")
var HSF = $ ("input[name^= ' Meals" +i+ "']"); Get all the food for a country
var gzf = $ ("input[name^= ' Miscellaneous" +i+ "']"); Access to all public and miscellaneous expenses in a country



Zsf.each (function (j) {//j) is the state's subscript for all types of accommodation charges
var zsftype = this;
countrys.accommodation=zsftype.value;//Set up accommodation fees
var rsobj = $ ("input[id^= '" "+zsftype.name+" RS "]");
Rsobj.each (function (z) {
var fyitems = {
' ID ': ',
' Credate ': Today,
' GroupId ': groupId,
' Budgetid ': Fahterid.val (),
' Days ': ',
' member ': ',
' Flag ': '
}
var m3 = this;
var tsnum = $ ("input[id^= '" "+zsftype.name+" ts '] ") [z]; Number of people who get the number of days
Number of fyitems.member=m3.value;//accommodation charges
Number of days fyitems.days=tsnum.value;//accommodation fee
fyitems.flag= ' 1 ';//set the corresponding indication of accommodation fee
Countrys.fydata.push (Fyitems); Get all accommodation fees in a country
Zsfrstotal +=parseint (M3.value); Total number of statistical accommodation charges
});

});


Hsf.each (function (j) {//j) is the subscript for all food types in the country
var hsftype = this;
countrys.meals=$ ("input[name^= ' Meals" +i+ "']"). Val ();//Set Meal
var hsfrsobj = $ ("input[id^= ' mealsmiscellaneous" +i+ "rs ']");
Hsfrsobj.each (function (z) {
var fyitems = {
' ID ': ',
' Credate ': Today,
' GroupId ': groupId,
' Budgetid ': Fahterid.val (),
' Days ': ',
' member ': ',
' Flag ': '
}
var hsfnum = this;
var tsnum = $ ("input[id^= '" "+hsfnum.name+" ts '] ") [z]; Number of people who get the number of days
Number of fyitems.member=hsfnum.value;//meals
Number of fyitems.days=tsnum.value;//meals
fyitems.flag= ' 2 ';//set the label for the food
Countrys.fydata.push (Fyitems); Get all the food for a country
Hsfrstotal +=parseint (Hsfnum.value); Total number of food and food statistics
});

});
Gzf.each (function (j) {//j) is the subscript for all public miscellaneous types of the state
var gzftype = this;
countrys.miscellaneous=$ ("input[name^= ' Miscellaneous" +i+ "']"). Val ();//Set Public miscellaneous fees
var gzfrsobj = $ ("input[id^= ' mealsmiscellaneous" +i+ "rs ']");
Gzfrsobj.each (function (z) {
var fyitems = {
' ID ': ',
' Credate ': Today,
' GroupId ': groupId,
' Budgetid ': Fahterid.val (),
' Days ': ',
' member ': ',
' Flag ': '
}
var gzfnum = this;
var tsnum = $ ("input[id^= '" "+gzfnum.name+" ts '] ") [z]; Number of people who get the number of days
Number of fyitems.member=gzfnum.value;//for public incidentals
Number of days for fyitems.days=tsnum.value;//public incidentals
fyitems.flag= ' 3 ';//set the label for the food
Countrys.fydata.push (Fyitems); Get all accommodation fees in a country
Gzfrstotal +=parseint (Gzfnum.value); Total number of public and miscellaneous expenses statistics
});
});
var groupmember = <%=groupNum%>; Get the number of groups
if (groupmember!= ' &&groupmember!=null) {
if (Zsfrstotal>groupmember) {
Alert ("The total number of accommodation charges can not be greater than the group number, please re-fill!");
Return
}
if (Hsfrstotal>groupmember) {
Alert ("The total number of food can not be greater than the group number, please re-fill!");
Return
}
if (Gzfrstotal>groupmember) {
Alert ("The total number of public miscellaneous expenses cannot be greater than the group size, please re-fill!");
Return
}

}
Data.push (Countrys);

});




if (!isnumber ($ (' input[name^= "overseas"]). Val ()) | |! Isnumber ($ (' input[name^= ' Traffic "]). Val ()) | |! Isnumber ($ (' input[name^= ' Miscellaneous "]). Val ()) | |! Isnumber ($ (' input[name^= ' meals "]). Val ()) | |! Isnumber ($ (' input[name^= ' accommodation "]). Val ()) | |! Isnumber ($ (' input[name^= ' domestic "]). Val ()) | |! Isnumber ($ (' input[name^= ' airport "]). Val ()) | |! Isnumber ($ (' input[name^= ' flights "]). Val ()) | | !isnumber ($ (' input[name^= "" visa "). Val ())) {
Alert (' Input cannot be empty and is a number! ‘);
return false;
}else if ($ (' input[name^= "currency"]). val () = = ') {
Alert (' Please enter currency! ');
return false;
}else{//judge the number of accommodation, food, public miscellaneous fees can not be empty!
$ (' tr[id^= ' ZSF "]). each (function () {
if ($ (this). Find (' input[id= "ACCOMMODATION0RS"]). val () = = ') {
Alert ("The number of accommodation charges cannot be empty!")
return false;
}else if ($ (this). Find (' input[id= "accommodation0ts"] '). val () = = ') {
Alert ("The number of nights cannot be empty!")
return false;
}
});
$ (' tr[id^= ' HSF "]). each (function () {
if ($ (this). Find (' input[id= "MEALSMISCELLANEOUS0RS"]). val () = = ') {
Alert ("The number of food, public and miscellaneous expenses cannot be empty!")
return false;
}else if ($ (this). Find (' input[id= "mealsmiscellaneous0ts"] '). val () = = ') {
Alert ("The number of meals, expenses, days cannot be empty!")
return false;
}
});
}




$.ajax ({
Type: "Post",
URL: "/internation/internationbudgetaction.do?method=saveview&groupid=${internationgroupvoe.groupid}& flag= "+flag+" ",
Data:{datalist:encodeuri (json.stringify (data))},
DataType: ' JSON ',
Success:function (response) {
Alert (' Save information Success! ‘);
},
Error:function (response) {
Alert (' Save message failed! ‘);
}
});
/**
if (!isnumber (' Input[name= "Domestictotal"]). Val ()) | |!isnumber ($ (' Input[name= "overseastotal"] '). Val ()) {
Alert (' Subtotal should be a number! ‘);
return false;
}*/
Document. Internationbudgetvoe.method.value= ' Saveview ';
Document.  Internationbudgetvoe.submit (); Submit a temporary comment
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.