The form is functioning properly on mobile devices but is currently experiencing issues on the server

Everything runs smoothly when accessing the website and using the form on localhost. However, once it's uploaded to a server, the form only functions correctly on desktop devices. On mobile, the form fails to filter and displays all professionals instead. The website is constructed with bootstrap and javascript.



<script type="text/javascript">
  window.onload=function(){
var element1 = document.getElementById("link-index");
element1.classList.remove("active");
     var element = document.getElementById("link-profesionales");
     element.classList.add("active");
}
</script>
<div class=" p-2" style="background-color: #f2f3f4;">
<nav class="" aria-label="breadcrumb">
  <div class=" col-sm-1 col-md-12 col-lg-12">
    <ol class="breadcrumb">
      <li class="ms-lg-5 ms-4 breadcrumb-item"><a class="breadcrumb-css" href="index.php">Inicio</a></li>
      <li class="breadcrumb-item active" aria-current="page">Profesionales</li>
    </ol>
  </div><h1 class="ms-lg-5 ms-4">Profesionales</h1>
</nav>
</div>

<style type="text/css">

/* Create three equal columns that floats next to each other */
.column {
  display: none; /* Hide columns by default */
  
}

/* Clear floats after rows */
.row:after {
  content: "";
  display: table;
  clear: both;
}

/* Content */
.content {
  background-color: white;
  
}

/* The "show" class is added to the filtered elements */
.show {
  display: block;
}

.card-footer{
position:absolute;
  bottom:0;
  width:100%;
  background-color: white;
}

.form-select:focus {
  border-color: #FFBE2C;
  outline: 0;
  box-shadow: 0 0 0 0.25rem #FFBE2C;
}
/* 
select option {
    background-color: #FFBE2C;
    font-weight: bold;
    color: white;
}

 
select option:checked{
    box-shadow: 0 0 10px 100px #1882A8;
    background-color: #FFBE2C;
    font-weight: bold;
    color: white;
}
*/
</style>

<div class="container">
    <div class="row">
<div class="mt-5 col-12 text-center">

<div class="btn-group col-auto" role="group" aria-label="Basic example">
  <form class="" method="GET" action="profesionales.php" id="formprofeesionales" >
    <label style="font-weight: bold;" for="exampleFormControlInput1" class="form-label col-md-8">Consultar por Especialidad:</label>
    <select id="select1" onchange="filterSelection('all')" class="form-select" aria-label="Default select example">
  <option selected value="all">Todos</option>
  <option onclick="filterSelection('Fisioterapia')" value="Fisioterapia">Fisioterapia</option>
  <option onclick="filterSelection('Fonoaudiología')" value="Fonoaudiología">Fonoaudiología</option>
  <option onclick="filterSelection('Psicología')" value="Psicología">Psicología</option>
</select>
</form>
</div>
</div>
</div>




<!-- Portfolio Gallery Grid -->
<div class="row row-cols-2 g-2 row-cols-md-6 mt-1">
  
  <div class="border-0 me-lg-4 my-lg-4  col card column Fonoaudiología">
    <div class="content">
      <div class="h-100 card ">
  <img src="https://www.bizkaiatalent.eus/wp-content/uploads/2014/05/ETB_Estibaliz-Ruiz-de-Azua1.jpg" class="img-thumbnail card-img-top border-0" alt="mountains">
  <div class="card-body">
    <h5 class="card-title">María Silvina Luchino</h5>
    <p class="card-text">Fonoaudiologa</p>
    <p class="mb-5 card-text">MP 34567</p>
    </div>
    <div class="card-footer"><a href="#" class="especialidades btn btn-sm">Contactar</a></div>
  
        </div>
    </div>
  </div>

  ...

<!-- END GRID -->
</div> 
        
    


</div>


<?php include 'footer.html'; ?>

The form is visible on mobile but does not filter or function properly. What could be causing this issue? Thank you for your help!

Answer №1

Get rid of all event listeners attached to the select element. Follow the example provided below.

<select id="select1" class="form-select" aria-label="Default select example">
  <option selected value="all">All</option>
  <option value="Physical Therapy">Physical Therapy</option>
  <option value="Speech Therapy">Speech Therapy</option>
  <option value="Psychology">Psychology</option>
</select>

Subsequently, include a sole event listener in your JavaScript file. This listener will be triggered by the change event on the #select1 element. Upon change, it grabs the current value of the select element (which corresponds to the selected option) and forwards it to the filterSelection function.

$(document).ready(function() {
  $('#select1').on('change', function() {
    const value = $(this).val();
    filterSelection(value);
  });
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to display additional information in typeahead using Angular JS

Currently, I am using the Bootstrap directory typeahead in Angular. I am looking to display more results in my HTML template instead of just the name: typeahead="job as job.name for job in getJobPlace($viewValue) | filter:{name:$viewValue}" I would like ...

Adjusting the width of innerHtml within a React router link to match the parent element's width

My current challenge involves a table where a cell is represented as a link. Within this setup, I am incorporating html content into the text of the link: <TableCell align="left" classes={{root: classes.cellPadding}}> <Link className={classes.l ...

Transmitting client-side Javascript data to backend server using Express

I am trying to fetch data from my frontend using the DOM and send it to the backend through Express but I'm unsure of how to proceed. I have used a POST method to console.log the data, but now I need help retrieving it in my Express backend. (The cons ...

Using an xmlhttprequest to retrieve a PDF file functions properly in synchronous mode, but encounters issues in

Today I'm experimenting with some code that scrapes PDFs from a chrome extension by detecting user-clicked links. I've noticed that synchronous xmlhttprequests work perfectly for both HTML documents and PDFs. However, I seem to be facing an issue ...

Error: Property 'blogCategory' is unreadable because it is undefined

Having trouble rendering blog posts from a json file in React const BlogPost = (props) => { const [post, setPost] = useState({ id: "", blogCategory:"", blogTitle:"", postedOn:"", ...

Having trouble with the basic function of jQuery radio buttons, unable to make them work properly

Struggling with my first attempt at incorporating jQuery into my project. I have set up 2 radio buttons on a form, and I want the selected option to update the value of an input text box within the same form. However, despite my best efforts, I just can&ap ...

In this guide, learn the best way to dynamically adjust image height to match the height of any device

I am trying to make sure that the image on the front page of my website fits the height of the screen or device, and resizes responsively without cropping when the device height changes. How can I achieve this? If you need a visual example of what I mean, ...

How can I enhance this conversion function from an Array to an Object in JavaScript?

Looking to construct an object consisting of empty arrays using values as keys. const CATEGORIES = ['apple', 'banana', 'orange'] generateCategoryObject() === { apple: [], banana: [], orange: []} function generateCategoryO ...

"Encountering a problem with the client-session middleware: the value of req.session_state is becoming undefined

I'm facing an issue with client-session middleware in Express. After setting the session_state, it doesn't seem to be accessible when redirecting to a new route. I followed a tutorial on YouTube (client-session part starts at around 36:00) and do ...

By pressing the "showMore" button, the page dynamically pulls in a json list from a file

Currently, my focus is on a dropwizard-Java project. My task involves retrieving and showcasing the first 10 items from a json list in a mustache view. If the user clicks on the "show more" link, I should retrieve the next 10 elements from the list and d ...

What is the best way to pass the text of a selected option in a dropdown menu to a function when a button is clicked in AngularJS?

Alright, so I've got this HTML page with a select element. The select has three options defined in the $scope below: <div id="mainID" ng-controller="theController"> <form name="assetTypeForm" class="form-horizontal" role="form" novalidat ...

Tips for arranging Angular Material cards in columns instead of rows

I am currently developing a web application using Angular, and I've encountered an issue while trying to display cards in a vertical layout rather than horizontally. My goal is to have the cards fill up the first column (5-6 cards) before moving on to ...

The issue of duplicate backgrounds appearing on the burger menu when adjusting the height

There seems to be an issue with my burgermenu; when I attempt to adjust the height, the background-color ends up duplicating. .bm-menu { background-color: rgba(255, 255, 255, 0.9); height: 60vh; position: fixed; transition: top 0.3s; to ...

Tips for aligning an element to the bottom of its container

Can you please make some major edits and then re-open? I am currently developing a page using Bootstrap 2.3.2, which will eventually serve as a template for Joomla 3.x. Within the header section, I have successfully positioned 6 elements as per the desi ...

Experimenting with a Jest test on an express middleware

I'm currently faced with a challenge in testing my controller (express middleware) using Jest. To better illustrate the issue, I will share the code snippet below: import request from 'utils/request'; import logger from 'config/logger& ...

The state object in Redux Toolkit remains static, resulting in the error message "Uncaught TypeError: Cannot assign to read only property 'property-name' of object '#<Object>'"

I'm facing an issue where I am trying to update the data of a state object in Redux Toolkit but it's not changing, and instead throwing an error that says Uncaught TypeError: Cannot assign to read only property 'status' of object ' ...

The alignment of margins appears as intended in Opera, Chrome, and IE, but unfortunately it does not

I have exhausted all possible options, but I am still struggling to get this page to appear correctly in Firefox. When you click inside the square, a menu with images should display on the right side. It is properly aligned in every browser except for Fire ...

How to retrieve response cookies using RxJS Ajax

When using RxJS to make an Ajax call request, I am able to set the headers of the request. However, I am wondering how I can retrieve the Cookie from the RxJS Ajax Response? import { ajax } from 'rxjs/ajax'; ajax({ url: "some url", body: ...

Transmit a JSON object while simultaneously receiving the corresponding response

As part of a school project, I need to work with JSON. The server will process the file and send back a response in JSON format. This entire exchange needs to be done using JavaScript. I recently learned about the XMLHttpRequest object, but I'm still ...

Utilizing Material UI (mui) 5.0 within an iframe: Tips and tricks

Attempting to display MUI components within an iframe using react portal has resulted in a loss of styling. Despite being rendered within the iframe, MUI components seem to lose their visual appeal when displayed this way. Most resources discussing this is ...