1

i am using struts1 in java and database is oracle 10g.I want to set value in a parent window in ajax when clicking a link from child window.Here,json data is retrieved but not set in the field.Any solution???Please help me............

Here is My JSP Code-------------------

 function doClick(v1,v2){
  
  var f = document.importLetterOfCreditBookingForm;
    var v3=window.opener.document.importLetterOfCreditBookingForm.LCLimitTypeCode.value;
     var v4=window.opener.document.importLetterOfCreditBookingForm.LCAccountTypeCode.value;
     var v5=window.opener.document.importLetterOfCreditBookingForm.LCBookingNumber.value;
  window.opener.document.importLetterOfCreditBookingForm.customerCode.value = v1;
  window.opener.document.importLetterOfCreditBookingForm.customerName.value = v2;
           
  /*f.action="/mybank/enterLCDetailsListOfImportLetterOfCreditBooking.do";
  f.submit();*/
  $(document).on('click', function (){
  $.ajax({
    type:'get',
       url:'/mybank/enterLCDetailsListOfImportLetterOfCreditBookingJson.do?LCLimitTypeCode='+v3+'&LCAccountTypeCode='+v4+'&LCBookingNumber='+v5+'&customerCode='+v1,             
            dataType:'json',
   success: function(data){ 
   
  f.LCLimitTypeCode.value = data.LCLimit;
  f.LCAccountTypeCode.value = data.LCAccountType;
  f.LCBookingNumber.value = data.LCBookingNo;
  f.customerCode.value = data.CustCode;
  f.customerName.value = data.CustName;
  f.customerAddess.value = data.CustAddress;
  
  f.bangladeshBankLCNumber.value = data.BBBankLcNo;
  f.partyDebitAccountTypeCode.value = data.PartyDebAccountCode;
  f.partyDebitAccountNumber.value = data.PartyDebAccountNo;
  f.partyDebitAccountTitle.value = data.PartyDebAccountTitle;
  f.IRCNumber.value = data.IRCNo;
  f.vatRegistrationNumber.value = data.VatRegiNo;
  f.TINNumber.value = data.TinNo;
  f.bankRegistrationNumber.value = data.BankRegiNo;
  f.LCFinanceCode.value = data.LCFinanceCode;
  f.sactionId.value = data.SanctionId;
  f.sanctionSerialNumber.value = data.SanctionSrlNo;
 f.sanctionAmount.value = data.SanctionAmount;
  f.LCBookingAmount.value = data.LCBookingAmount;
  f.LTROutstanding.value = data.LTROutstanding;
  f.PADOutstanding.value = data.PADOutstanding;
  f.availableGlobalLimit.value = data.AvailableGlobalLimit;
  f.sanctionAuthotiryCode.value = data.SanctionAuthotiryCode;
  f.sanctionNumber.value = data.SanctionNumber;
  //f.sanctionDate.value = data.SanctionDate;
  //f.sanctionDay.value = data.SanctionDay;
  f.LCAFNumber.value = data.LCAFNumber;
  //f.LCAFDate.value = data.LCAFDate;
  //f.LCAFDay.value = data.LCAFDay;
  f.LCAFAmountLC.value = data.LCAFAmountLC;
  //f.bookingDate.value = data.BookingDate;
  //f.bookingDay.value = data.BookingDay;
  f.foreignLCCode.value = data.ForeignLCCode;
  f.negotiationCode.value = data.NegotiationCode;
  f.formOfLCCode.value = data.FormOfLCCode;
  f.recourseAllowedCode.value = data.RecourseAllowedCode;
  f.categotyCode.value = data.CategotyCode;
  f.typeOfLCCode.value = data.TypeOfLCCode;
  f.sightPercentage.value = data.SightPercentage;
  f.communicationMediaCode.value = data.CommunicationMediaCode;
  f.drawee.value = data.Drawee;
  f.rateCode.value = data.RateCode;
  f.tradeTermCode.value = data.TradeTermCode;
  f.countryOfOriginCode.value = data.CountryOfOriginCode;
  f.countryOfOriginCodeDesc.value = data.CountryOfOriginCodeDesc;
  f.beneficiaryId.value = data.BeneficiaryId;
  f.beneficiaryName.value = data.BeneficiaryName;
  f.beneficiaryAddress.value = data.BeneficiaryAddress;
  f.modeOfTransportCode.value = data.ModeOfTransportCode;
  f.availableByCode.value = data.AvailableByCode;
  f.availableWithCode.value = data.AvailableWithCode;
  f.ammendmentNumber.value = data.AmmendmentNumber;
  //f.ammendmentDate.value = data.AmmendmentDate;
  //f.dateOfIssue.value = data.DateOfIssue;
  //f.LCIssueDay.value = data.LCIssueDay;
  f.LCExpiryDate.value = data.LCExpiryDate;
  //f.LCExpiryDay.value = data.LCExpiryDay;
  f.placeOfExpiry.value = data.PlaceOfExpiry;
  //f.shipmentDate.value = data.ShipmentDate;
  f.shipmentPeriod.value = data.ShipmentPeriod;
  f.currencyCode.value = data.CurrencyCode;
  f.exchangeRate.value = data.ExchangeRate;
  f.tolerancePercentagePositive.value = data.TolerancePercentagePositive;
  f.tolerancePercentageNegative.value = data.TolerancePercentageNegative;
  f.LCOpenValueFCY.value = data.LCOpenValueFCY;
  f.LCOpenValueLCY.value = data.LCOpenValueLCY;
  f.LCCurrentValueFCY.value = data.LCCurrentValueFCY;
  f.LCCurrentValueLCY.value = data.LCCurrentValueLCY;
  f.LCValueFCY.value = data.LCValueFCY;
  f.LCValueLCY.value = data.LCValueLCY;
  f.statusOfCreditCode.value = data.StatusOfCreditCode;
  f.usanceInDays.value = data.UsanceInDays;
  f.fromPort.value = data.FromPort;
  f.transportTo.value = data.TransportTo;
  f.shipmentPeriod.value = data.ShipmentPeriod;
  f.partshipmentAllowedCode.value = data.PartshipmentAllowedCode;
  f.transhipmentAllowedCode.value = data.TranshipmentAllowedCode;
  f.confirmInstructionCode.value = data.ConfirmInstructionCode;
  f.transferableCode.value = data.TransferableCode;
  f.LCStatus.value = data.LCStatus;
  f.advisingBankCode.value = data.AdvisingBankCode;
  f.advisingBranchCode.value = data.AdvisingBranchCode;
  f.advisingBankCodeDesc.value = data.AdvisingBankCodeDesc;
  f.adviseThroughBankCode.value = data.AdviseThroughBankCode;
  f.adviseThroughBranchCodeDesc.value = data.AdviseThroughBranchCode;
  f.adviseThroughBankCodeDesc.value = data.AdviseThroughBankCodeDesc;
  f.negotiatingBankCode.value = data.NegotiatingBankCode;
  f.negotiatingBranchCode.value = data.NegotiatingBranchCode;
  f.negotiatingBankCodeDesc.value = data.NegotiatingBankCodeDesc;
  f.transferingBankCode.value = data.TransferingBankCode;
  f.transferingBranchCode.value = data.TransferingBranchCode;
  f.transferingBankCodeDesc.value = data.TransferingBankCodeDesc;
  f.reimbursingBankCode.value = data.ReimbursingBankCode;
  f.reimbursingBranchCode.value = data.ReimbursingBranchCode;
  f.reimbursingBankCodeDesc.value = data.ReimbursingBankCodeDesc;
  f.confirmingBankCode.value = data.ConfirmingBankCode;
  f.confirmingBranchCode.value = data.ConfirmingBranchCode;
  f.confirmingBankCodeDesc.value = data.ConfirmingBankCodeDesc;
  f.applicantBankCode.value = data.ApplicantBankCode;
  f.applicantBranchCode.value = data.ApplicantBranchCode;
  f.applicantBankCodeDesc.value = data.ApplicantBankCodeDesc;
  f.insuranceBankCode.value = data.InsuranceBankCode;
  f.insuranceBranchCode.value = data.InsuranceBranchCode;
  f.insuranceBankCodeDesc.value = data.InsuranceBankCodeDesc;
  f.insuranceCoverNoteNumber.value = data.InsuranceCoverNoteNumber;
  //f.insuranceCoverNoteIssueDate.value = data.InsuranceCoverNoteIssueDate;
  //f.insuranceCoverNoteDay.value = data.InsuranceCoverNoteDay;
  f.indentPerformFlagCode.value = data.IndentPerformFlagCode;
  f.indentPerformInvoiceNumber.value = data.IndentPerformInvoiceNumber;
  //f.indentPerformInvoiceDate.value = data.IndentPerformInvoiceDate;
  f.indentPerformInvoiceValue.value = data.IndentPerformInvoiceValue;
  f.indentorNameAndAddress.value = data.IndentorNameAndAddress;
  f.CCIAndERegistrationNumber.value = data.CCIAndERegistrationNumber;
  f.bangladeshBankPerformanceNumber.value = data.BangladeshBankPerformanceNumber;
  f.CRFCompany.value = data.CRFCompany;
  f.sequenceTotal.value = data.SequenceTotal;
  f.periodPresent.value = data.PeriodPresent;
  f.charges.value = data.Charges;
  f.statusOfTrnsDocumentCode.value = data.StatusOfTrnsDocumentCode;
  f.overseasBankChargePaidByCode.value = data.OverseasBankChargePaidByCode;
  f.instruction.value = data.Instruction;
  f.sendToReciver.value = data.SendToReciver;
  f.documentRequired.value = data.DocumentRequired;
  f.conditions.value = data.Conditions;
  f.additionalConditions.value = data.AdditionalConditions;
  f.availableGlobalLimit.value = data.Available;
  f.goodsDetails.value = data.GoodsDetails;
  f.HSCode.value = data.HSCode;
  
    }  
    }); 
  });  
    
  window.close();
    }
 <td valign="top" class="lbl-08" align="center"><a href="#" onClick="doClick('<%=sCustomerID%>','<%=sCustomerName%>')"><font class="link-b-08"><%=sSelect%></font></a></td>

2 Answers2

0

If you have defined a global variable in your parent window like

var var1 = "value1" 

then you can simply access/change it in child window using

parent.var1 = "value2"

If you want to change form elements of parent window from child window, you can set it like

 window.opener.document.getElementById('textbox1').value="put your value here";

See similar threads here and here.

Community
  • 1
  • 1
rahimv
  • 541
  • 4
  • 12
  • Main problem is that here the action which is called from child i.e., url:'/mybank/enterLCDetailsListOfImportLetterOfCreditBookingJson.do?LCLimitTypeCode='+v3+'&LCAccountTypeCode='+v4+'&LCBookingNumber='+v5+'&customerCode='+v1 is thoroughly working.But it's "success " part is not working.what to do??? – Shahin Baly Aug 03 '15 at 09:18
0

i.ve solved my question.just replace the code 'window.close()' inside the success part.But now i faced e new problem.the null value retreive from database is set as 'undefined' in the screen.How can handle this undefined in struts1 using ajax.......