Ajax obtains the name and class by ID

Source: Internet
Author: User

<% @ Page contenttype = "text/html; charset = gb2312" %>
<Script language = "JavaScript">
<! --

VaR XMLHTTP;

 

Function createxmlhttprequest (){

If (window. activexobject ){

XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");

}

Else if (window. XMLHttpRequest ){

XMLHTTP = new XMLHttpRequest ();

}

}

 

Function queryuserinfo (){

VaR jrntl_id = Document. getelementbyid ("jrntl_id"). value;
 
If (jrntl_id = ""){
Return;
}

 

VaR url = "../JSP/gywork/getinfo. jsp? Userid = "+ jrntl_id;

 

Createxmlhttprequest ();

XMLHTTP. onreadystatechange = handleaddstatechange;

XMLHTTP. Open ("get", URL, true );

XMLHTTP. Send (null );

}

Function handleaddstatechange (){

If (XMLHTTP. readystate = 4 ){

If (XMLHTTP. Status = 200 ){

VaR responsexml = XMLHTTP. responsexml;
VaR queryresult = responsexml. getelementsbytagname ("queryresult") [0]. firstchild. nodevalue;

If ("failed" = queryresult ){

} Else {
VaR name = responsexml. getelementsbytagname ("name") [0]. firstchild. nodevalue;
VaR bank_id = responsexml. getelementsbytagname ("bank_id") [0]. firstchild. nodevalue;
VaR bank_name = responsexml. getelementsbytagname ("bank_name") [0]. firstchild. nodevalue;
Document. getelementbyid ("counter_name"). value = Name;
Document. getelementbyid ("jrnbr"). value = bank_id;
Document. getelementbyid ("jrnbr_name"). value = bank_name;

}

}

Else {

Alert ("An error occurred while obtaining background data! ");

}

}

}

 

Function getjrnac_dat (){
Var val = showmodaldialog ("../report/calendar.htm", window, "status: No; dialogwidth: 250px; dialogheight: 250px ");
If (typeof (VAL )! = "Undefined ")
Document. handaddfrm. jrnac_dat.value = val;
}
Function getadd_date (){
Var val = showmodaldialog ("../report/calendar.htm", window, "status: No; dialogwidth: 250px; dialogheight: 250px ");
If (typeof (VAL )! = "Undefined ")
Document. handaddfrm. add_date.value = val;
}
Function interonsubmit (){
VaR alerttext = "";
VaR flag = false;
If (! Isstringlong (document. getelementsbyname ('jrntl _ id') [0]. Value, 4 )){
Alerttext + = "the clerk's character string is too long/N ";

}
If (document. getelementsbyname ('jrntl _ id') [0]. value = ""){
Alerttext + = "the clerk's character string cannot be blank/N ";

}
If (! Isstringlong (document. getelementsbyname ('jrnbr ') [0]. Value, 6 )){
Alerttext + = "the row number string is too long/N ";

}
If (document. getelementsbyname ('jrnbr ') [0]. value = ""){
Alerttext + = "The line number character cannot be blank/N ";

}
If (! Isstringlong (document. getelementsbyname ('jrnbr _ name') [0]. Value, 30 )){
Alerttext + = "the row name string is too long/N ";

}
If (document. getelementsbyname ('jrnbr _ name') [0]. value = ""){
Alerttext + = "the row name string cannot be blank/N ";
 
}
If (! Isstringlong (document. getelementsbyname ('jrntr _ cod ') [0]. Value, 4 )){
Alerttext + = "the transaction number string is too long/N ";
 
}
If (document. getelementsbyname ('jrntr _ cod ') [0]. value = ""){
Alerttext + = "the transaction number character cannot be blank/N ";

}
If (! Isstringlong (document. getelementsbyname ('jrntr _ cod_name ') [0]. Value, 30 )){
Alerttext + = "the transaction name string is too long/N ";

}
If (document. getelementsbyname ('jrntr _ cod_name ') [0]. value = ""){
Alerttext + = "the transaction name string cannot be blank/N ";

}
If (! Isnum (document. getelementsbyname ('scvvhamt0 ') [0]. Value, 19,2 )){
Alerttext + = "the transaction amount is not a floating point number/N ";
 
}
If (document. getelementsbyname ('scvvhamt0 ') [0]. value = ""){
Alerttext + = "the transaction amount can be 0, and cannot be blank/N ";
 
}
If (alerttext! = ""){
Alert (alerttext );
} Else {
Document. Forms [0]. Submit ();
}
}
// -->
</SCRIPT>

<Link href = "$ {skin. stylepath}/style.css" rel = stylesheet type = text/CSS>

 

<Form action = "block. $ {requestmap. blockkey }. edit. function. handaddinsert "name =" handaddfrm "method =" Post "onsubmit =" Return dohandaddsubmit (this); ">

<Table border = "0" cellspacing = "0" cellpadding = "0" style = "border-collapse: collapse; margin-bottom: 3px" class = "$ {skin. stylename} "id =" $ {requestmap. blockkey} "width =" 100% ">
<Tr>
<TD class = "skin_title" colspan = 3>
<Table width = "100%" border = "0" style = "border-collapse: collapse" cellspacing = "0" cellpadding = "0">
<Tr>
<TD class = "skin_left" nowrap = "true"> </TD>
<TD class = "skin_middle" width = "100%" nowrap = "true" background = "$ {skin. stylepath}/images/title_bg.gif "> -- <B> Add </B>
<A href = "javascript: openhelp ('newseditdetail ')"> </a>
</TD>
<TD class = "skin_right" align = "right"> </TD>
</Tr>
</Table>
</TD>
</Tr>
<Tr>
<TD class = "skin_body_left" background = "$ {skin. stylepath}/images/content_left_bg.gif"> </TD>
<TD class = "skin_body">
<Table cellspacing = "0" cellpadding = "1" width = "100%">

<Tr>
<TD> Clerk Number: </TD>
<TD> <input type = "text" id = "jrntl_id" name = "jrntl_id" value = "" size = "40" onpropertychange = "queryuserinfo (); "> clerk name: <input type =" text "id =" counter_name "name =" counter_name "value =" "size =" 40 "> </TD>
 
 
<TD> row number: </TD>
<TD> <input type = "text" id = "jrnbr" name = "jrnbr" value = "" size = "40"> </TD>
</Tr>
<Tr>
<TD> row name: </TD>
<TD> <input type = "text" id = "jrnbr_name" name = "jrnbr_name" value = "" size = "40"> </TD>
 
<TD> transaction No.: </TD>
<TD> <input type = "text" name = "jrntr_cod" value = "" size = "40"> </TD>
</Tr>
<Tr>
<TD> transaction name: </TD>
<TD> <input type = "text" name = "jrntr_cod_name" value = "" size = "40"> </TD>
 
<TD> transaction amount: </TD>
<TD> <input type = "text" name = "scvvhamt0" value = "" size = "40"> </TD>
</Tr>
<Tr>
<TD> Transaction date: </TD>
<TD> <input type = "text" name = "jrnac_dat" readonly onclick = "getjrnac_dat ()" value = "" size = "40"> </TD>
</Tr>
 
<Input type = "hidden" name = "responseurl" value = "block. $ {requestmap. blockkey}. Edit. function. handaddeditlist" size = "40">
<Input class = "button" type = "button" onclick = interonsubmit () value = "Submit"/>
<Input class = "button" type = "reset" value = "reset"/>
<Input class = "button" onclick = "location. href = 'block. $ {requestmap. blockkey }. edit. function. handaddeditlist '; "type =" button "value =" return "/>

$ Requestmap. gettoken ()
</Form>
</Table>
</TD>
<TD class = "skin_body_right" background = "$ {skin. stylepath}/images/content_right_bg.gif"> </TD>
</Tr>
<Tr>
<TD colspan = "3" class = "skin_bottom">
<Table width = "100%" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<TD class = "skin_bottom_left"> </TD>
<TD class = "skin_bottom" background = "$ {skin. stylepath}/images/bottom_bg.gif" width = "100%"> </TD>
<TD class = "skin_bottom_right"> </TD>
</Tr>
</Table>
</TD>
</Tr>
</Table>

 

Related Article

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.