2017-04-24 7 views
-3

ドロップダウン私はmaterializecss送信値は、私は別のAJAX機能</p> ここ<p>あるにドロップダウンリストから値を送信したいリストTP個別のAJAX機能

で使用するドロップダウンリストのために使用することを私のコードの一部
 <a class='dropdown-button btn' href='#' data-activates='dropdown1'>choisir le temp d'arrivée !</a> 


<ul id='dropdown1' class='dropdown-content'> 
<li><a href="#!">5 minutes</a></li> 
<li><a href="#!">10 minutes</a></li> 
<li><a href="#!">15 minutes</a></li> 

とAjax機能

 function isochroneIGN(lat, lng) { 
    var urlign = 'http://wxs.ign.fr/rvahvdprhlyejxbib0gemjzn/isochrone/isochrone.json'; 
    $.ajax({ 
     url: urlign, 
     data: { 
     location: lng+','+lat, 
     method: 'Time', 
     graph: 'Pieton', 
     graphName: 'Pieton', 
     exclusions: '', 
     time: 5000, 
     holes: true, 
     smoothing: true 
     }, 
     type: 'GET', 
     dataType: 'json', 
     success: function(res) { 
     layerGroup.clearLayers(); 
     var wkt = new Wkt.Wkt(); 
     wkt.read(res['wktGeometry']); 
     var feature = wkt.toObject(); 
     feature.setStyle({ 
      color: '#FF0000', 
      fill: true, 
      fillColor: '#FF0000', 
      fillOpacity: 0.2 
     }); 
     layerGroup.addLayer(feature); 
     map.fitBounds(layerGroup.getBounds()); 
     }, 
     error: function(res) { 
     console.log(res); 
     } 
    }) 
    } 

私は時間変数

にドロップダウンリストのjqueryの値を送信したいです

助けてくれてありがとう、

+0

このドロップダウンは?です。それはonchange関数と一緒に来なければならない – Rhea

+0

それはajax関数に値を送るべきドロップダウンリストを実現する – reda

答えて

0
// manually bind the value 
$('#dropdown1 li').click(function(){ 

    $('#dropdown1').attr('data-val', $(this).attr('value')); 
}) 
// and use it as 
$.ajax{ ..... 
    time: $('#dropdown1').attr('data-val') 
    } 
+0

それは、ありがとう – reda

関連する問題