Here's my problem:

I have an html gadget (gadget.xml) that fetches content from a remote
webpage (remote.php - a site that I own with my content) and displays
the contents of remote.php on the gadget and auto adjusts height of
the gadget depending on the height of the remote.php (remote.php has
dynamic content where its height changes all the time). No problems so
far...

Content of remote.php is actually a form that has a number of radio
buttons. As its content is fetched as text and loaded on gadget.xml,
the users click on the "submit" button to post the information they
enter on the form to another page (results.php) which also gets
displayed within the gadget (no pop-ups or new external windows)

Now, height of the results.php is different from the height of
remote.php, so I have to do another _IG_AdjustIFrameHeight() operation
with onsubmit so that height of the gadget auto adjusts for the height
of the results.php page

Do I know the height of results.php page in advance so that I can send
the proper value onsubmit? Yes I do, but that information is available
in the remote.php page. Meaning, depending on how many 'radio
buttons' (i.e. occurances of <input type="radio"....> tags) there are
on the remote.php page, I know what the height of my results.php
should be. For instance, if there are 4 radio buttons in remote.php
(e.g. a form with 4 options), my results.php page's height should be
400px... if 5 radio buttons, height should be 500px, etc.

Here's the code that I have in the html section of gadget.xml:

<script type="text/javascript">
 function fetchURL() {
  var url = "http://www.mydomain.com/remote.php";;
   _IG_FetchContent(url, function(responseText) {
    _gel('content_div').innerHTML = responseText;

        var haystack = responseText;
        var needle = 'radio'; //need to find how many times text radio
appears
        var countOccurance = 0;
                for (var i=0;i<haystack.length;i++) {
                if (needle == haystack.substr(i,needle.length))
                countOccurance++;
                }
        var newheight = 100*(countOccurance);
                function adjust_height(){
                _IG_AdjustIFrameHeight(newheight);
                }
        }, { refreshInterval: (60 * 5) });
 }
_IG_RegisterOnloadHandler(fetchURL);
</script>

<form action="http://www.mydomain.com/results.php"; method="post"
name="radio_form" onsubmit="return (adjust_height())">
<div id="content_div"></div>
</form>

This code fetches the remote.php page and displays it fine. It also
gets populates the "newheight" variable properly depending on how many
times text "radio" occurs in the fetched content (e.g. if I
document.write newheight, I can see it return the desired value such
as 400 or 500). But it is throwing a javascript error and not resizing
the height of the results.php for the newheight value. You may say
that this is a javascript question rather than a gadget one, but
perhaps there is a better way of doing this with the use of
_IG_AdjustIFrameHeight() more elegantly...

One final note, If I use _IG_AdjustIFrameHeight(400) for onsubmit
rather than adjust_height()), everything works just fine. But I need
to be using a variable as opposed to a fixed value such as "400" so if
I try _IG_AdjustIFrameHeight(newheight) for instance, it tells me that
newheight is not defined since it is a local variable as opposed to a
global one.

Sorry for the long post, but I am hoping someone can offer help with
this.

Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iGoogle Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Gadgets-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to