Showing posts with label Java Script. Show all posts
Showing posts with label Java Script. Show all posts

Tuesday, September 11, 2007

Struts Html Drop Downs n JS

Long time for me make the struts drop down work..

I basicaly need 3 standard values in my drop down..
1) select ""
2) long term
3) short term


Here is the html code:


Select...
Short Term - less than or equal to 180 days
Long Term - more than 180 days


Value from the form(sArcfacilityGradeForm.facilityTenorValue) is preselected in the dropdown

Here is the JS Function:

function tenorChange(tenroObj){
var tenor=tenroObj.value;
alert('Changing tenor on screen');
alert('tenor value read from screen is :'+tenor);
//document.forms[0].tenor.value=tenor;
//alert('display tenor value from form'+tenorScrenn);
if (tenor == "") {
alert('Please select a valid tenor');
tenroObj.value=document.forms[0].facilityTenorValue.value;
return false;
}
document.forms[0].tenorScreenValue.value=tenor;

//document.forms[0].facilityTenorValue=tenorScrenn;
document.forms[0].action.value = "changeTenor";
document.forms[0].submit();
}

Input: tenroObj is dropdown object used to display on the screen.
var tenor=tenroObj.value; ==> will contain the value selected
ex: From Short Term - less than or equal to 180 days
if short term -less than or equal to 180 days is selected on the screen, this value contains: 179.


You can only set String values from JS to Form. So here,
tenorScreenValue: Has to be a String value in the Facility Grade Form.

document.forms[0].tenorScreenValue.value=tenor;

Very Important Note: Form values you are trying to set from Java Script must be defined as hidden variables in the JSP or JS wont be able to read them

Ex:

Tuesday, August 28, 2007

Setting Focus to Apt section of the page

DG page has the following:
CI
SI
RI
DG
When user changes a value in RI user shud be brought back to RI, instead of the beginning of the page where he will have to scroll into the apt section.
here is how we'll do id:

Declare div values for each section of your page and

Set the value in ur action class on pg submit

facilityGradeForm.setShowRegClass(true);
facilityGradeForm.setShowCI(false);
facilityGradeForm.setShowGuarantee(false);
facilityGradeForm.setshowOS(false);
facilityGradeForm.setShowDG(false);

Call a generic js fn on pg load to scroll into the div value on submit.
function setAptPageFocus(){

//alert("IN apt page focus");
//alert(document.forms[0].showGuarantee.value);
if (document.forms[0].showGuarantee.value=="true"){
//alert("In Show Guarantee");
divShowGuarantee.scrollIntoView();
}

if (document.forms[0].showOS.value=="true"){
//alert("In Show OS");
divShowOtherSupport.scrollIntoView();
}

if (document.forms[0].showRegClass.value=="true"){
//alert("In SHow Reg Class");
divShowRegClass.scrollIntoView();
}

if (document.forms[0].showCI.value=="true"){
//alert("In SHow CI");
divShowingCI.scrollIntoView();
}

}

Each page submit will take you to apt section of the page yay.!!

Tuesday, June 12, 2007

pop up windows in JS

WOrking with popup windows in JS

function submitMenu(submitType,proposalElementId,clientGradingStatus,proposalType){

if(submitType == "viewFacPrevGR"){
dgPopUp(submitType,proposalElementId);
}
}


//POPUP FUNCTION

function dgPopUp(submitType,proposalElementId)
{
// alert("Inside dgPopUp");
document.forms[0].action.value=submitType;
window.open("about:blank", "viewFacPrevGR", "width=900,height=600,SCROLLBARS,dependent,resizable");
//window.open("about:blank", "sArcViewPreviouGR", "location=0,toolbar=0,menubar=0,resizable=1,modal=yes");

document.forms[0].target = "viewFacPrevGR";
document.forms[0].selectedProposalElementId.value = proposalElementId;
document.forms[0].submit();
}


window.open("/srgt-arc/actions/validateResult.do", "ValidationResult", "width=700,height=400,SCROLLBARS");

Itsy bitsy ava Script

Working with PopUp windows.. :)

hey first time I ever created a popup window today.. I am so happy .. yay!!!

here is the code to create one..

function submitMenu(submitType,proposalElementId,clientGradingStatus,proposalType){

if(submitType == "viewFacPrevGR"){
dgPopUp(submitType,proposalElementId);
}

}


function dgPopUp(submitType,proposalElementId)
{
alert("Inside dgPopUp");
document.forms[0].action.value=submitType;
window.open("about:blank", "viewFacPrevGR", "width=900,height=600,SCROLLBARS,dependent,resizable");

document.forms[0].target = "viewFacPrevGR";
document.forms[0].selectedProposalElementId.value = proposalElementId;
document.forms[0].submit();
}



or you can directly call it from your JS as:


window.open("/srgt-arc/actions/validateResult.do", "ValidationResult", "width=700,height=400,SCROLLBARS");


learning is fun :)