• Sultan

    (@sultan_semmaiyahoocom)


    my script is

    function($) {
       var google_map_address = $('#address').text();
    $(function () {
    $('#gmap').gmap3({
        marker: {
            address: google_map_address
        },
        map: {
            options: {
                zoom: 14
            }
        }
    }); });})(jQuery);

    and my php code is

    init_shortcode();
        function init_shortcode() {
        $shortcodes = array(
        'gmap' => 'spyrowebs_gmap');
        foreach( $shortcodes as $tag => $func )
            add_shortcode( $tag, $func );
        }
        function spyrowebs_gmap( $atts = array(), $content = '' ) {
        $defaults = array(
            'address' =>'',
          );
        $atts = shortcode_atts( $defaults, $atts );
        extract( $atts );
        $address=$address;
        return ' <div class="gmap" id="gmap"><div id="address" style="display:none">'.$address.'</div></div>';
    }

    but this does not work i want to create a shortcode like

    [gmap address="your address"]

    now what is the problem when i assign a value to javascript variable like

    var google_map_address = 'your address';

    then its work while in the above its not working please any help.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Set variable in javascript and using in my shortcode’ is closed to new replies.