views:

196

answers:

2

I have hidden field on thick box, when I close thick I need to get the value of my hidden field, when close thick box this method calls

function tb_remove(parent_func_callback) {
parent.document.getElementById('hdf').value// I need value of hidden field here

please tell me how can I get hidden field value that is on thick box?

e.g I have page abc, I click on heyperlink from page abc, then page xyz open as thick box, on xyz thickbox I have hidden field name hdf, now I click on close button of thick box, tb_remove is called that's in thickbox.js file, I need to get the value of hdf here in js file to use in abc page.

Thanks

+5  A: 

Well if I understand the question correctly, 'hdf' is the ID of the hidden field, so this will get you the value then... If I have misunderstood let me know.

I assume by thick box you mean you want to get a control inside an iframe or something similiar... here's how.

var hdfVal = $('#myIFrameID').contents().find('#hdf').val();

Or simply, just need to get a value of a control by ID...

var hdfVal = $('#hdf').val();
gmcalab
I am getting undefined. please note I want to get this value thickbox.js, when user click close on thick box, then this method called thickbox.js file tb_remove(parent_func_callback) , I need the value here
Muhammad Akhtar
Give me some code in your question so I can see what's going on then.
gmcalab
e.g I have page abc, I click on heyperlink from page abc, then page xyz open as thick box, on xyz thick box I have hidden field name hdf, now I click on close button of thick box tb_remove is called that's in thickbox.js file, I need to get the value of hdf here js file to use in abc page.
Muhammad Akhtar
I will have to see some code to know how your thick box is working. There's lots of different ways to implement something like that. i.e. iframes...
gmcalab
Muhammad Akhtar
@gmcalab; thanks for your reply. I think you have understand my problem. I will be grateful to you if provide me quick solution
Muhammad Akhtar
Have you tried implementing as an iframe instead? I will have to think about this one since its a reference to another page. What does the code render like, have you used firebug to see what the code looks like when you first open the thickbox? If you can see what the code looks like when the thickbox is open, you might be able to understand what sort of selector you will need. Is the thickbox already closed when this method is called? If it is I could see why the element can't be found. If you can trap it before it closes and get the value that would be a step closer...
gmcalab
no its not closed, but I am getting value in where thickbox close function do this task function tb_remove(parent_func_callback) {// here I am trying to get the value }
Muhammad Akhtar
Ok, well look at code in firebug after you open the thickbox and see how it looks. Then we can get a better idea of what sort of selector we need to access the element.
gmcalab
I have put hidden field on abc main page, I am getting the value of that hidden field instead of thick box hidden field in same place
Muhammad Akhtar
thanks alot, your first solution work for me.
Muhammad Akhtar
A: 

Are you using ThickBox to wrap an iframe? If not, try just:

document.getElementById('hdf').value;
Matt Gibson
no its not working.
Muhammad Akhtar
If you read the question, he has already tried this.
gmcalab
@gmcalab Perhaps I'm being blind today, but I've read the question twice again now, and I can't see where it says he's already tried this. Can you point it out for me? Thanks.
Matt Gibson
@Matt Gibson `function tb_remove(parent_func_callback) {parent.document.getElementById('hdf').value// I need value of hidden field here`
gmcalab
@gmcalab That says _parent_.document.getElementById(). Which will only work if you're inside an iframe, looking for an element in a parent frame. I'm suggesting dropping the "parent", and looking for the element in the current document. Get me?
Matt Gibson