The same kind of functionality when implemented in a DCT , works fine without any problem
function handle_selection(date) { var calloutForm = eval($form_name); if (!calloutForm) { alert('Can not get the Form ' + '$form_name'); return; } var not_found = true; for ( i = 0 ; i < calloutForm.elements.length ; i++ ) { if (calloutForm.elements.name == '$item_name') { calloutForm.elements.value = date; not_found = false; break; } } if (not_found) { alert('Can not find element ' + '$item_name'); } self.close();}
I use different callouts for metadata and templating....
You have problems finding opener's Form or Item. So...What is your Version and Platform?How did you set $form_name and $item_name in your CGI? Note that Forms themselves and posted information differs between DCR Form and MD Form. Tryfunction handle_selection(date) { var calloutForm = eval($form_name); if (!calloutForm) { alert('Can not get the Form ' + '$form_name'); return; } var not_found = true; for ( i = 0 ; i < calloutForm.elements.length ; i++ ) { if (calloutForm.elements.name == '$item_name') { calloutForm.elements.value = date; not_found = false; break; } } if (not_found) { alert('Can not find element ' + '$item_name'); } self.close();}
function Now the problem openers form is resolved and I am able to set the value, butthe value is not getting populated in the fieldHere is the modified code .It has some alert statements included to check the values.In the earlier posted code I was not able to get into the if block,but here I am able to and all the alerts which I included work fine.The alert messages that come when this function is invoked arealert(calloutForm) will alert----------"[object]"alert(calloutForm.elements.name); will alert----"Teamsite/Metadata/md.publishDate" ---this is the item name in MD formalert(calloutForm.elements.value);will alert----"2007-02-22"----this is the date I selcted in the calendar widgetfunction handle_selection(date){ if ((window.opener == null) || (window.opener.closed)) { return false; } var calloutForm = eval('opener.document.$form_name'); if (!calloutForm) { return false; } alert(calloutForm); for ( i = 0 ; i < calloutForm.elements.length ; i++ ) { if (calloutForm.elements.name == '$item_name') { alert(calloutForm.elements.name); calloutForm.elements.value = date; alert(calloutForm.elements.value); break; } } self.close(); }
And I tried the code you given,but it is also not working
Now the problem openers form is resolved and I am able to set the value, but the value is not getting populated in the field...
So is there any mechanism which will help us to collect the openers form name......
New FormAPI callout syntax makes this *callback* search obsolete for DCTs anyway. For legacy CGI code that I want to use in both DCT/MD Forms $ENV{HTTP_REFERER} allows to distinguish.
are you traveller from the future, my friend? formAPI is not supported in metadata DCTs.... as yet. wait till 6.7.1, SP1 - end of Q2 2007..
Once again, how did you set $form_name and $item_name in your code? In other words, what hash keys did you use?$form_name = $cgi->{'form'}{????};$item_name = $cgi->{'form'}{????};Hi, ISCBorisbofirst Thanks for your very useful reply,This is how I am setting the values you said.my $form_name = $cgi->{'form'}{'iw_form_name'};my $item_name = $cgi->{'form'}{'iw_item_name'};
Unfortunately, no :-). That's why I've clarified "for DCT anyway" in my post. What I should have said is probably "regular" DCT, non-MD DCT or some such nonsense.Please note Kisnak's argument though... His CGI is working in "regular" DCT but not MD and he's trying to make it work for both.That's what prompted my remark.
I myself have 2 calendar widgets - one for DCT, another - for MDCT. the difference is JavaScript in there. Never thought of having all in one....
Whether same CGI callout code for both DCT and MDCT is a good idea is debatable.In any case, $ENV{HTTP_REFERER} allows to find out the caller type (DCT or MDCT)
Hi,I got the solution,Unknowingly I missed the return statement in my function, and I overlooked the same mistake all the time when I see it.anyways thanks for your help guys.
Hi Kisnak,I am also having the same problem with cgi. Could you please post the code that you have corrected. thanks in advance.Suri