Jump to content

reveret

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About reveret

  • Rank
    Newbie
  1. I have searched in vain for an answer to this problem, but I am getting no where. Here is the issue: I have a search form that works fine as a desktop application. On mobile devices there is a problem. If a user starts typing in the search input, and then taps one of the words that pops up in predictive text (such as on an iphone), this word then fills the input. The search form returns no matches because, as I have discovered, the only thing being submitted is what the user actually typed before tapping the predictive hint. For example, if they start typing Pennsylvania but only type "Pennsy" and then tap the suggestion, the only value in the input is "Pennsy," not the whole word. I have seen some suggestions: for example, setting the input type to 'password' prevents predictive suggestions (and thus requiring the user to type out the entire term), but this also triggers hiding the text submitted (as if it were a password). I have also seen some suggest that you could use setTimeout() before ajax submits the form to the server, but this did not work either and I am not quite sure of the logic behind this solution anyway. Is there a way for javascript / jquery to "read" the value of an input that the user filled by means of tapping predictive text? Thanks in advance' reveret
  2. Thanks again. I'll try it out.
  3. Thanks for your quick response. I should have been clearer. I am using the query you suggested: SELECT * FROM table WHERE letter = ? But I am using it four times, once for each letter and thus one for each tab. I have a process file (process.php), and in that file I do the four database queries: <?php require_once('config.php'); // Connect to database // $mysql = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // get data for A // $A_data = $mysql->query("SELECT * FROM profiles WHERE letter = 'A'"); while($row = $A_data->fetch_object()) { $A_results[] = $row; } // get data for B // $B_data = $mysql->query("SELECT * FROM profiles WHERE letter='B'"); while($row = $B_data->fetch_object()) { $B_results[] = $row; } ... and the same for C and D. In index.php, I require process.php and in each of the four tab-pane sections, I use a foreach loop. So a user clicks on tab A, and each "A" row is output as a bootstrap card as shown below. <div class="container"> <div class="row"> <?php foreach ($A_results as $A_result) : ?> <div class='col-md-4 col-sm-6 col-lg-3'> <div class='card mt-5'> <div class='card-body'> <p><?php echo($A_result->name); ?></h4> <p>Date: <?php echo ($A_result->date); ?></p> <p>Address: <?php echo($A_result->address); ?></p> </div> </div> </div> <?php endforeach; ?> </div> </div> I do the same thing for B, C, and D. This works fine, but it seems hopelessly redundant. Now that you have seen my code, would you still suggest I go with the code you provided? Or is there something else I could try? Thanks again for your help.
  4. I am new to web development, so be patient please I am working with a tab navigation system. It happens to be bootstrap, but this question is not specific to bootstrap. There are four tabs; for the sake of simplicity we will call them tabs "A", "B", "C", and "D." I have a single SQL table and one of the columns --we will call it "Letter"-- identifies each row with one of the four letters. When a user clicks on "A" tab, they should see all the rows where "Letter" = "A". The same for tabs "B", "C", and "D." Right now I am running four separate queries, one for each tab. This seems ridiculous. There must be a way to grab all the data from the table with one query, sort the rows based on their "Letter" into four separate multi dimensional arrays, and then loop through the appropriate array to display the data for a particular "Letter" when a user selects that tab. I cannot figure out how to do this. Any suggestions would be most helpful. Thanks.
×
×
  • Create New...