I m returning one value from pop up window now i want is the text box value changes from pop up window it should change its background color to red, otherwise no change will be reflect. What m i doing is
<input type="button" id="button1" value="button1" style="width:95%;font-family:Verdana;font-size:9px;" onclick="window.open( '<%= Url.Action( "PopUp", "Home" ) %>' ,'popup','height=410','width=200','target=popup','center','front');" onfocus="if(document.getElementById('HiddenVal').value!=null||document.getElementById('HiddenVal').value!=''){txtbutton.value=document.getElementById('HiddenVal').value ; document.getElementById('H开发者_开发百科iddenVal').value='';}" />
where txtbutton is text box and button1 is the button which open the pop up window. I want to change the color of text box if its value changed; otherwise its background should be white.
remove your onfocus code from button and then place this code inside your js file.
$('#button1').focus(function(){
if(document.getElementById('HiddenVal').value!=null&&document.getElementById('HiddenVal').value!=''){
$('#txtbutton', window.parent.document).css("background-color","red"); //Assuming txtbutton is ID of your textbox
document.getElementById('HiddenVal').value='';
}
} );
one more way you can try is write a function inside your parent window and then call that function from child window-something like this-
<script>
function ifDoneChild(val) {
$('#txtbutton').css("background-color","red");
}
</script>
call this function from child window-
$('#button1').focus(function(){
if(document.getElementById('HiddenVal').value!=null&&document.getElementById('HiddenVal').value!=''){
window.parent.ifDoneChild();
}
});
精彩评论