Click here to Skip to main content
14,669,501 members
Home » Discussions » JavaScript
   

JavaScript

 
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
MemberMember 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
MemberMember 1261817013-Apr-20 23:05 
QuestionRead email from outlook and display on website javascripts Pin
Member 147950937-Apr-20 3:31
MemberMember 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
Membersimpledeveloper11-Mar-20 6:51 
QuestionHow can I get an input value from ajax result search Pin
vlafratta4-Mar-20 4:45
Membervlafratta4-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
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
$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.
QuestionRe: How can I get an input value from ajax result search Pin
ZurdoDev4-Mar-20 5:12
mveZurdoDev4-Mar-20 5:12 
AnswerRe: How can I get an input value from ajax result search Pin
vlafratta5-Mar-20 3:39
Membervlafratta5-Mar-20 3:39 
GeneralRe: How can I get an input value from ajax result search Pin
ZurdoDev5-Mar-20 3:50
mveZurdoDev5-Mar-20 3:50 
GeneralRe: How can I get an input value from ajax result search Pin
vlafratta5-Mar-20 4:54
Membervlafratta5-Mar-20 4:54 
AnswerRe: How can I get an input value from ajax result search Pin
ZurdoDev5-Mar-20 5:10
mveZurdoDev5-Mar-20 5:10 
GeneralRe: How can I get an input value from ajax result search Pin
vlafratta16-Mar-20 1:41
Membervlafratta16-Mar-20 1:41 
SuggestionRe: How can I get an input value from ajax result search Pin
Richard Deeming6-Apr-20 1:30
mveRichard Deeming6-Apr-20 1:30 
QuestionFunction showMessage not available Pin
vinnie moag28-Feb-20 15:04
Membervinnie moag28-Feb-20 15:04 
AnswerRe: Function showMessage not available Pin
Richard MacCutchan28-Feb-20 22:45
mveRichard MacCutchan28-Feb-20 22:45 
Questiondrawing A Random Bezier Curve 10 times then reset Pin
LarsAlaska28-Feb-20 11:21
MemberLarsAlaska28-Feb-20 11:21 
AnswerRe: drawing A Random Bezier Curve 10 times then reset Pin
Graham Breach28-Feb-20 19:54
MemberGraham Breach28-Feb-20 19:54 
QuestionThere is some problem in my code I could not get the bus seat layout seats. Please help me Pin
Member 1465358023-Feb-20 22:45
MemberMember 1465358023-Feb-20 22:45 
SuggestionRe: There is some problem in my code I could not get the bus seat layout seats. Please help me Pin
Richard Deeming23-Feb-20 23:01
mveRichard Deeming23-Feb-20 23:01 
QuestionHow does this work in Javascript? Pin
Nand3210-Feb-20 23:25
MemberNand3210-Feb-20 23:25 
AnswerRe: How does this work in Javascript? Pin
Richard Deeming11-Feb-20 1:09
mveRichard Deeming11-Feb-20 1:09 
GeneralRe: How does this work in Javascript? Pin
Nand3211-Feb-20 1:27
MemberNand3211-Feb-20 1:27 
QuestionValidate if my drop location is not empty using JS(HTML DnD API) Pin
Member 147327851-Feb-20 20:04
MemberMember 147327851-Feb-20 20:04 

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.