Click here to Skip to main content
15,886,422 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: using javascript geoplugin to geolocalize Pin
Member 1480782320-Apr-20 6:52
Member 1480782320-Apr-20 6:52 
GeneralRe: using javascript geoplugin to geolocalize Pin
ZurdoDev20-Apr-20 7:08
professionalZurdoDev20-Apr-20 7:08 
GeneralRe: using javascript geoplugin to geolocalize Pin
Member 1480782320-Apr-20 7:43
Member 1480782320-Apr-20 7:43 
AnswerRe: using javascript geoplugin to geolocalize Pin
layarfilm215-May-20 3:01
layarfilm215-May-20 3:01 
QuestionSuper simple for everyone else... Pin
JaHowler17-Apr-20 12:49
JaHowler17-Apr-20 12:49 
AnswerRe: Super simple for everyone else... Pin
Jin Vincent Necesario17-Apr-20 19:35
professionalJin Vincent Necesario17-Apr-20 19:35 
GeneralRe: Super simple for everyone else... Pin
JaHowler18-Apr-20 8:24
JaHowler18-Apr-20 8:24 
AnswerRe: Super simple for everyone else... Pin
Richard Deeming20-Apr-20 0:44
mveRichard Deeming20-Apr-20 0:44 
QuestionClick ok button in alert then chaining methods. Pin
Member 1265872416-Apr-20 12:00
Member 1265872416-Apr-20 12:00 
AnswerRe: Click ok button in alert then chaining methods. Pin
Richard Deeming17-Apr-20 4:00
mveRichard Deeming17-Apr-20 4:00 
Questionwhat is javascript and what can I make with it? Pin
Rapid Spray16-Apr-20 1:00
professionalRapid Spray16-Apr-20 1:00 
AnswerRe: what is javascript and what can I make with it? Pin
dioscarey17-Apr-20 7:11
dioscarey17-Apr-20 7:11 
QuestionHow to use Open Street map or any other Map Offline with web application Pin
Member 1451287515-Apr-20 1:29
Member 1451287515-Apr-20 1:29 
QuestionRe: How to use Open Street map or any other Map Offline with web application Pin
Richard MacCutchan15-Apr-20 1:52
mveRichard MacCutchan15-Apr-20 1:52 
AnswerRe: How to use Open Street map or any other Map Offline with web application Pin
Member 1451287515-Apr-20 2:20
Member 1451287515-Apr-20 2:20 
GeneralRe: How to use Open Street map or any other Map Offline with web application Pin
Richard MacCutchan15-Apr-20 2:29
mveRichard MacCutchan15-Apr-20 2:29 
GeneralRe: How to use Open Street map or any other Map Offline with web application Pin
Member 1451287515-Apr-20 2:32
Member 1451287515-Apr-20 2:32 
GeneralRe: How to use Open Street map or any other Map Offline with web application Pin
Richard MacCutchan15-Apr-20 2:40
mveRichard MacCutchan15-Apr-20 2:40 
GeneralRe: How to use Open Street map or any other Map Offline with web application Pin
Member 1451287515-Apr-20 2:48
Member 1451287515-Apr-20 2:48 
QuestionRe: How to use Open Street map or any other Map Offline with web application Pin
Richard MacCutchan15-Apr-20 3:06
mveRichard MacCutchan15-Apr-20 3:06 
QuestionHow to read Doc or Pdf file using javascript or jquery Pin
Member 1261817013-Apr-20 23:05
Member 1261817013-Apr-20 23:05 
QuestionRead email from outlook and display on website javascripts Pin
Member 147950937-Apr-20 3:31
Member 147950937-Apr-20 3:31 
AnswerRe: Read email from outlook and display on website javascripts Pin
Richard Deeming7-Apr-20 3:45
mveRichard Deeming7-Apr-20 3:45 
Question./watch is compiling the JS library files mostly but one file it is always caching Pin
simpledeveloper11-Mar-20 6:51
simpledeveloper11-Mar-20 6:51 
QuestionHow can I get an input value from ajax result search Pin
vlafratta4-Mar-20 4:45
vlafratta4-Mar-20 4:45 
Hello, I'm new here.
I am designing an intranet, of which I require that the user when making a request for a product will be able to select it directly from the database and send that request.

From the page where the requests originate, I added a search button for the user to search for the specific product and add it to their product request, this was done with ajax live search.

From the results of that search, a list is usually displayed with the possible results, the objective, and it is where I am blocked, is that from the list with the results, the user chooses the one he wants and this is inserted in the request for the parent page.

I have these live search files in ajax, php and mysql:

search-form.php (popup):

PHP
<?php
session_start();
$_SESSION['username'];
$link = mysqli_connect("localhost", "user", "", "database");
  if ($link === false) {
    die("ERROR: Could not connect. " . mysqli_connect_error());
  }
?>
<html>
<head>
  <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&language=en"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="../../bower_components/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="../../bower_components/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="../../bower_components/Ionicons/css/ionicons.min.css">
  <link rel="stylesheet" href="../../dist/css/AdminLTE.min.css">
  <link rel="stylesheet" href="../../dist/css/skins/skin-blue.min.css">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
<script>
$(document).ready(function(){
  load_data();
  function load_data(query)
    {
      $.ajax({
      url:"backend-search.php",
      method:"POST",
      data:{query:query},
      success:function(data){
        $('#result').html(data);
      }
    });
  }
$('#search').keyup(function(){
  var search = $(this).val();
    if(search != ''){
      load_data(search);
    }else{
      load_data();
    }
 });
});
</script> 
</head>
<body>
<div class="container-fluid">
  <div class="wall">
    <section class="content">
          <div class="box box-default">
          <div class="box-header with-border"></div>
            <div class="box-body">
              <div class="row">
              <h3>Ricerca Prodotto</h3>
                <div class="col-xs-12">
                  <input type="text" name="search" id="search" placeholder="Cerca il codice" class="form-control" style="width: 300px;" />
                  <div id="result"></div>
                </div>
                </div>
            </div>
          </div>
      </section>
    </div>
 </div>
 </body>
 </html>

backend-search.php (same popup)
PHP
<?php
$link = mysqli_connect("localhost", "user", "", "database");
if ($link === false) {
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
$content = '';
    if (isset($_POST["query"])) {
        $search = mysqli_real_escape_string($link, $_POST["query"]);
        $query = $sql = "SELECT * FROM spesa_articoli_disponibili WHERE Codice_Articolo_CAPP LIKE '%" . $search . "%' OR  ARTICOLO_Descrizione LIKE '%" . $search . "%'";
        }
    $result = mysqli_query($link, $query);
    if (mysqli_num_rows($result) > 0) {
    $content .= '
                <div class="table-responsive">
                <table class="table table-bordered" id="item_table">
                <div class="group">
                </div>';
    while ($row = mysqli_fetch_assoc($result)) {
        $codice = $row["Codice_Articolo_CAPP"];
        $articolo = $row["ARTICOLO_Descrizione"];
        $content .= '
                <div>
                    <div>
                        <table class="table table-bordered">
                        <form method="post" id="searchform">
                                <tr>
                                    <th>Codice Articolo</th>
                                    <th>Descrizione Articolo</th>

                                </tr>
                        </div>
                            <div>
                                <tr>
                                    <td><input type="number" id="codice" name="codice" value="' . $codice . '" style="width: 70px;" readonly="readonly" /></td>
                                    <td><input type="text" id="articolo" name="articolo" value="' . $articolo . '" style="width: 100%" readonly="readonly" /></td>
                                    <td><input type="button" value="Aggiungi" onclick="getValue();" /></td>
                                    <td><a href="JavaScript:window.close()">Chiudi</a></td>
                                </tr>
                            </div>
                        </form>
                    </table>
                    <div id="resultado"></div>
                </div>';
            }
    echo $content;
        } else {
            echo "Non ci sono risultati. Riprova.";
            }
mysqli_close($link);
?>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script  type="text/javascript">
    function getValue() {
            var codice = window.opener.document.getElementById("codice");
            codice.value = document.getElementById("codice").value;
            var articolo = window.opener.document.getElementById("articolo");
            articolo.value = document.getElementById("articolo").value;
        }
        window.close();
    }
</script>


So far I have not been able to select the search result and send the values to the parent page.
Ideas, help, suggestions, all will be well received.

Thanks in advance.
Valter.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.