Mike,

Thanks very much for your reply.

I want to wait until the infoWindow with the input fields exists
and then I want the user to already have the only text input
field to be in focus ready for him/her to type.

I made the change you suggested on line 65 and tried running
again, but with no change in focus. Do markers even have
focus()?

http://schott.selfip.net/~brian/mapswdelete/rideshare.html

     63 var iwform = 'Enter your name:<br>'
     64 + '<form onsubmit="process(this); return false" action="#">'
     65 + '  <input type="text" name="data" id="data" size="31"
maxlength="31"/>        '
     66 + '  <input type="submit" value="Submit" />'
     67 + '<\/form>';
     68
     69 function whenReady( id, callback ) {
     70     var interval = setInterval( function() {
     71         var element = document.getElementById( id );
     72         if( element ) {
     73             clearInterval( interval );
     74             callback( element );
     75         }
     76     }, 10 );
     77 }


     84 GEvent.addListener(marker, "click", function() {
     85 lastmarker = marker;
     86 marker.openInfoWindowHtml(iwform);
     87 whenReady( 'data', function( marker) {
     88   marker.focus();
     89 });
     90 });
     91 noMore = true;
     92 map.addOverlay(marker);
     93 marker.openInfoWindowHtml(iwform);
     94 whenReady( 'data', function( marker) {
     95   marker.focus();
     96 });

Thanks for taking a look.

Brian in Atlanta


On Sat, Nov 22, 2008 at 11:11 AM, Michael Geary <[EMAIL PROTECTED]> wrote:
>
> Hi Brian,
>
> I assume you are trying to wait until the input element in your form exists,
> so you can set the focus to it?
>
> The whenReady() code uses document.getElementById(), but your input element
> has no id attribute. It does have:
>
> name="data"
>
> But getElementById() requres an id attribute. You can add:
>
> id="data"
>
> to the input element (in addition to the name="data" and everything else
> that's there now) to fix that.
>
>> I have tried 'data' for 'fromAddress' and both 'iwform' and 'marker'
>> for 'element', but without success.
>
> There's no reason why you would need to change the word "element" in that
> code. It's just a variable name with no significance to it.
>
> -Mike
>
> // == creates a draggable marker with an input form ==
> function createInputMarker(point,ID) {
> if(!noMore){
> var marker = new GMarker(point,{draggable:true, icon:G_START_ICON});
> marker.ID = ID + 0;
> GEvent.addListener(marker, "click", function() {
> lastmarker = marker;
> marker.openInfoWindowHtml(iwform);
> whenReady( 'data', function( marker) {
>  marker.focus();
> });
> });
> noMore = true;
> map.addOverlay(marker);
> marker.openInfoWindowHtml(iwform);
> whenReady( 'data', function( marker) {
>  marker.focus();
> });
> lastmarker=marker;
> return marker;
> }
> }
>
>> From: thebrianschott
>>
>> I found a fine answer to my question in a Michael Geary post
>> but the link to which his post refers (in an earlier post in
>> the thread) no longer exists and I have not figured out the
>> detailed references required (fromAddress, element, and maybe
>> others). Michael's post says the following.
>>
>>
>> *****************************************
>> Add this function to your code:
>>
>>     function whenReady( id, callback ) {
>>         var interval = setInterval( function() {
>>             var element = document.getElementById( id );
>>             if( element ) {
>>                 clearInterval( interval );
>>                 callback( element );
>>             }
>>         }, 10 );
>>     }
>>
>> Then, in your resetPvaMarkerInfo() function, immediately
>> after you call openInfoWindowHtml(), add this code:
>>
>>     whenReady( 'fromAddress', function( element ) {
>>         element.focus();
>>     });
>>
>> The whenReady() function takes an element ID and repeatedly
>> checks to see if that element exists. When the element
>> becomes available, it calls the callback function with that
>> element as an argument.
>> *****************************************
>>
>> Look for the following code in my link twice near line 86.
>> I have tried 'data' for 'fromAddress' and both 'iwform' and 'marker'
>> for 'element', but without success.
>>
>> marker.openInfoWindowHtml(iwform);
>>
>> http://schott.selfip.net/~brian/mapswdelete/rideshare.html
>>
>> Help, please.
>>
>> Brian in Atlanta
>> >
>
>
> >
>



-- 
(B=) <-----my sig
Brian Schott

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to