Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <form>
  2. <select name="event_option" onchange="showPrice(this.value)">
  3. <option value=""> Wybierz opcję</option>
  4. @foreach ($options as $option)
  5. <option value="{{ $option->id }}">{{ $option->name }}</option>
  6. @endforeach
  7. </select>
  8. </form>
  9.  
  10. <script>
  11. function showPrice(str) {
  12. if (str == "") {
  13. document.getElementById("price").innerHTML = "";
  14. return;
  15. } else {
  16. if (window.XMLHttpRequest) {
  17. // code for IE7+, Firefox, Chrome, Opera, Safari
  18. xmlhttp = new XMLHttpRequest();
  19. } else {
  20. // code for IE6, IE5
  21. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  22. }
  23. xmlhttp.onreadystatechange = function() {
  24. if (this.readyState == 4 && this.status == 200) {
  25. document.getElementById("price").innerHTML = this.responseText;
  26. }
  27. };
  28. xmlhttp.open("GET","getprice.php?q="+str,true);
  29. xmlhttp.send();
  30. }
  31. }
  32. </script>
  33.  
  34. <p id="price"> </p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement