Send selected data in an External Json list to email (Fipe Table Query)

Asked

Viewed 344 times

1

$(document).ready(function() {
  var urlBase = "http://fipeapi.appspot.com/api/1/carros/";
  $.getJSON(urlBase + "marcas.json", function(data) {
    var items = ["<option value=\"\">ESCOLHA UMA MARCA</option>"];
    $.each(data, function(key, val) {
      items += ("<option value='" + val.id + "'>" + val.name + "</option>");
    });
    $("#marcas").html(items);
  });
  $("#marcas").change(function() {
    $.getJSON(urlBase + "veiculos/" + jQuery(this).val() + ".json", function(data) {
      var items = ["<option value=\"\">ESCOLHA UM VEICULO</option>"];
      $.each(data, function(key, val) {
        items += ("<option value='" + val.id + "'>" + val.name + "</option>");
      });
      $("#veiculos").html(items);
    });
  });
  $("#veiculos").change(function() {
    $.getJSON(urlBase + "veiculo/" + jQuery("#marcas").val() + "/" + jQuery(this).val() + ".json", function(data) {
      var items = ["<option value=\"\">ESCOLHA O ANO</option>"];
      $.each(data, function(key, val) {
        items += ("<option value='" + val.id + "'>" + val.name + "</option>");
      });
      $("#ano").html(items);
    });
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<body>
  <select id="marcas">
        </select>
  <select id="veiculos">
        </select>
  <select id="ano">
        </select>
</body>

I made the code to load JSON using the base of this site http://fipeapi.appspot.com/ But I would like to send this data that you upload from Json by email. The query works well, because also could resume to present on the screen the complete concatenated data, but I am not knowing how to make the data selected in the list is stored in my database and also sent by email.

  • Oi Eduardo! You can not send emails directly from the browser. Either send by the server or via a website that has this service (via ajax).

  • Hi @Sergio, but it is not directly from the browser no, it is yes via a server, but I need to create an application in php that sends. In this case I improved the code and added these lines below that converts the .val() in .text() $("#nome_marca").html("<input name='" + "nome_marca" + "' value='" + $("#marcas option:selected").text() + "'/>"); in php uploadForm.php add $MARCA = $_REQUEST['nome_marca'] this is calling from the input that was created that receives the value #marcas option:selected.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.