Quick bit of Javascript help needed.

Quick bit of Javascript help needed.

Author
Discussion

BliarOut

Original Poster:

72,857 posts

240 months

Tuesday 5th October 2010
quotequote all
I have a child window which I open in FancyBox to update the properties of a MySQL table row. On submit it automatically close and refreshes the table it was called from. It all works fine, but I now want to transfer the value of a radio button in the child form to the parent irked All I need to do is have the parent radio button take on the value of the checkbox on the child, ie: open or closed.

{{{
//============================================================+
//Used to close FancyBox and reload the calling page.
//============================================================+
function closeFB()
{
//window.opener.document.radioControls.statusRadio.value = document.updateForm.Status.value;
window.parent.location = window.parent.location.href;
parent.$.fancybox.close();
}
}}}


I can alter the syntax to window.parent.document etc... but that doesn't work either frown What am I missing?

BliarOut

Original Poster:

72,857 posts

240 months

Tuesday 5th October 2010
quotequote all
Let me get this working first smile I'm planning to start using Ajax etc to make things more dynamic once I've got all the functionality I need but for consistencies sake I'd just like to do this with a simple js call.

BliarOut

Original Poster:

72,857 posts

240 months

Tuesday 5th October 2010
quotequote all
opener.document didn't work frown If it helps, I'm opening it in an iframe...

BliarOut

Original Poster:

72,857 posts

240 months

Tuesday 5th October 2010
quotequote all
What a prat. I'm calling this on the on submit action of a form... And the radio's no longer have a value banghead

So I've got the values of the radios' using their onclick property and I can pop them in an alert but I still can't set the value of the parent... How could I do that?

BliarOut

Original Poster:

72,857 posts

240 months

Tuesday 5th October 2010
quotequote all
I got it working with the code below but then hit another problem. The refresh of the parent then sets it back to it's default radio button and I can't be arsed to code my way out of it right now biggrin

FancyBox is a lightbox type library that I use in conjunction with another (niftycorners) to get a mac style window with rounded corners and transparency to display an inline iframe with transparency etc. It creates a very swish looking borderless window for data input/update in seconds.






If anyone is interested the working code is below, I changed the name of the Radio during testing...


{{{
//============================================================+
//Used to update the calling page.
//============================================================+
function updateParent()
{

callStatusVal = 0;

for( i = 0; i < document.updateForm.callStatus.length; i++ )
{
if( document.updateForm.callStatus[i].checked == true )
callStatusVal = document.updateForm.callStatus[i].value;
}
//alert( "Call Status Value Is = " + callStatusVal );
if (callStatusVal=='Open'){
window.parent.statusRadioOpen.checked = true;
}
if (callStatusVal=='Closed'){
window.parent.statusRadioClosed.checked = true;
}
window.parent.location = window.parent.location.href;
}
}}}