I have an iframe, which opens up in a modal. The contents are present in iframe.jsp. Now the iframe contains a drop down. On change of drop down i will call another window. However, if the user selects the option : camRip in the drop down options, then that window will not be called.
My code for on change looks like this :
<select id="hamStan" onchange = "callWindow('<%=URL %>');">
My on change is like this :
function callWindow(URL) {
var selectedByUser = document.getElementById("hamStan");
var strUserText = selectedByUser.options[selectedByUser.selectedIndex].text;
if(strUserText!="camRip ")
{
var windowName = "popUp";
var windowSizeArray = [ "width=740,height=400,top=10,left=50,toolbar=1,location=1,directories=0,status=0,menuBar=1,scrollBars=1,resizable=1"];
window.open(URL,windowName,windowSizeArray);
}
}
But the problem is selectedByUser is coming up as null. Where am i going wrong ? Kindly help . How do i get the drop down user selected value on change from the modal iframe.jsp ?
After a lot of research i finally found the solution .
This is what i fished up :
Be sure here that you are correctly accessing the iframe-id otherwise variable iframe will give you a type error. Hope it helps others.