Formulaire javascript

Fermé
GB12 Messages postés 2 Date d'inscription dimanche 4 avril 2010 Statut Membre Dernière intervention 9 avril 2010 - 4 avril 2010 à 19:11
GB12 Messages postés 2 Date d'inscription dimanche 4 avril 2010 Statut Membre Dernière intervention 9 avril 2010 - 9 avril 2010 à 14:01
Une question qui ne doit pas être compliquée pour un non débutant...

Je voudrais que l'affichage des coordonnées sur une carte google ajoute aussi la possibilité d'entrer ces coordonnées dans un carnet d'adresses

J'ai donc ajouté un formulaire dans le return de generateMarkerHtml: function(m) {
est-ce une bonne méthode ?
Sachant que je fais un test avec un input type="text" pour voir si je lis bien le code postal.
google locator affiche bien sa valeur (44000) avec m.test
comment faire pour que la value de input type="text" name="postcode" l'affiche aussi ?
Javascript ? php ? quelle variable utiliser ? Je n'y arrive pas, besoin d'un coup de main. PLEASE !!!

code modifié
<script type="text/javascript">
var ex;
(function(){
    var storeLocator = new UnirgyStoreLocator({
        mapEl: $('map'),
        sidebarEl: $('sidebar'),
        searchUrl: '<?php echo $this->getUrl('ustorelocator/location/search')?>',
        generateSidebarHtml: function(m) {
            return '<b>' + m.title + '</b> (' + parseFloat(m.distance).toFixed(1) + ' ' + m.units + ')<br/>'
                + m.address_display.replace(/\n/, '<br/>');
        },
        generateMarkerHtml: function(m) {
            var url = m.website_url.replace(/\s/,'');
            return '<b>' + m.title + '</b> <br/>'
                + m.street_address + '&nbsp;' + m.test + '&nbsp;' + m.city + '<br/>'
                + '<br/>'
                + '<form action="<?php echo $this->getSaveUrl() ?>" method="post" name="formulaire" id="form-validate">'
                + '<input type="hidden" name="country_id" value="" />'
                + '<input type="text" name="telephone" value="<?php echo $this->__('my default shipping address') ?>" />'+ '<br/>'
                + '<input type="text" name="postcode" value="" />'+ '<br/>'
                + '<input type="hidden" name="default_shipping" value="1" />'
                + '<button type="submit" title="<?php echo $this->__('my default shipping address') ?>" class="button"><span><span><?php echo $this->__('my default shipping address') ?></span></span></button>' + '<br/>'
                + '</form>'
                + '<br/>'
                + (m.phone.length>5 ? m.phone + '<br/>' : '')
                + (url.length>5 ? '<a href="' + (url.match(/@/) ? 'mailto:' : '') + url + '"><strong>' + url + '</strong></a><br/>' : '')
                /*
                + '<p>Product Types: '
                + (m.product_types.match(/baby/) ? 'Custom Baby; ' : '')
                + (m.product_types.match(/wedding/) ? 'Custom Wedding; ' : '')
                + (m.product_types.match(/card/) ? 'Greeting Cards; ' : '')
                + '</p>'*/
                + '<p>' + m.notes + '</p>';
        }
    });



code origine
<script type="text/javascript">
var ex;
(function(){
    var storeLocator = new UnirgyStoreLocator({
        mapEl: $('map'),
        sidebarEl: $('sidebar'),
        searchUrl: '<?php echo $this->getUrl('ustorelocator/location/search')?>',
        generateSidebarHtml: function(m) {
            return '<b>' + m.title + '</b> (' + parseFloat(m.distance).toFixed(1) + ' ' + m.units + ')<br/>'
                + m.address_display.replace(/\n/, '<br/>');
        },
        generateMarkerHtml: function(m) {
            var url = m.website_url.replace(/\s/,'');
            return '<b>' + m.title + '</b> <br/>'
                + m.street_address + '&nbsp;' + m.test + '&nbsp;' + m.city + '<br/>'
                + (m.phone.length>5 ? m.phone + '<br/>' : '')
                + '<br/>'
                + (url.length>5 ? '<a href="' + (url.match(/@/) ? 'mailto:' : '') + url + '"><strong>' + url + '</strong></a><br/>' : '')
                /*
                + '<p>Product Types: '
                + (m.product_types.match(/baby/) ? 'Custom Baby; ' : '')
                + (m.product_types.match(/wedding/) ? 'Custom Wedding; ' : '')
                + (m.product_types.match(/card/) ? 'Greeting Cards; ' : '')
                + '</p>'*/
                + '<p>' + m.notes + '</p>';
        }
    });
    
    Event.observe(window, 'load', function () {
        storeLocator.load();
 
<?php if ($_defaultLocation): ?>
        $('storelocator-results').style.visibility = 'visible';
        storeLocator.search('<?php echo addslashes($_defaultLocation) ?>', {
            radius: '<?php echo addslashes($_defaultRadius) ?>'
            /*, type: $('product_type').value*/
        });
<?php endif ?>
    });
    
    Event.observe(window, 'unload', GUnload);
 
<?php if ($_showSearch): ?>
    Event.observe($('store_locator_form'), 'submit', function() {
        $('storelocator-results').style.visibility = 'visible';
        storeLocator.search($('address').value, {
            radius: $('radius').value
            /*, type: $('product_type').value*/
        });
    });
<?php endif ?>
 
})();
</script>



1 réponse

GB12 Messages postés 2 Date d'inscription dimanche 4 avril 2010 Statut Membre Dernière intervention 9 avril 2010
9 avril 2010 à 14:01
Je cherche mais ne trouve pas.
Si qqn a une idée ou une piste à explorer ça fera mon bonheur !
0