Command field in Javascript

I've crafted an exquisite search box for my website, but I'm struggling to make it functional and display search results. Below are the Html and CSS files pertaining to this section of my site:

.searchbox{
    /*setting width of the form element*/
    width:350px;
    /*centering the form element*/
    margin-top: 200px;
    margin-left: 250px;
    margin-bottom: 370px;
}

input[type="search"]{
    padding:10px 15px 10px 50px;
    font-size:36px;
    color:#4D4D4D;
    /*removing border from search box*/
    border:none;
    /*using a search symbol as background image*/
    background-image:url(img/search-btn.png);
    background-repeat:no-repeat;
    /*adjusting background size*/
    -webkit-background-size:35px 35px;
    -moz-background-size:35px 35px;
    -o-background-size:35px 35px;
    background-size:35px 35px;
    /*positioning background image*/
    background-position:8px 12px;
    /*changing background color to white*/
    background-color:#C6E2FF;
}
 
/*modifying placeholder text color and ensuring cross-browser consistency*/
input[type="search"]::-webkit-input-placeholder{
    color:#0276FD;
}
input[type="search"]:-moz-placeholder { /* Firefox 18- */
    color: #0276FD;
}
input[type="search"]::-moz-placeholder { /* Firefox 19+ */
    color: #0276FD;
}
input[type="search"]:-ms-input-placeholder { /* internet explorer*/
    color: #0276FD;
}

form.searchbox a{
    display:block;
    /*removing underlines from anchor element*/
    text-decoration:none; 
    color:#1f5350;
    font-size:30px;
    background-color:#C6E2FF;
    padding:10px;
}

form.searchbox ul{
     width:465px;
    /*removing predefined bullet points from list*/
     list-style:none;
    /*removing padding from list items*/
    padding:0;
}

form.searchbox ul li{
    margin-bottom:10px;
}

/*adding hover effect to list item when hovered over with mouse*/
.searchbox ul li a:hover{
    color:#395D33;
    background:#8CDD81;
}

/*slight movement to the right on hover*/
.searchbox ul li:hover{
    /*transform*/
    -webkit-transform:translateX(20px);
    -moz-transform:translateX(20px);
    -ms-transform:translateX(20px);
    -o-transform:translateX(20px);
    transform:translateX(20px);
}

/*initially hiding suggestion list*/
.suggestions li{
    overflow:hidden;
    height:0;
    -webkit-transition:all 0.3s ease-in-out;
    -moz-transition:all 0.3s ease-in-out;
    -o-transition:all 0.3s ease-in-out;
    transition:all 0.3s ease-in-out;
}

/*showing suggestions when search field is focused*/
input[type="search"]:focus + .suggestions li{
    height:63px;
}
<section class="searcharea">
    <div class="wrapper">
        <form class="searchbox" action="Resources.html" target="_NEW">
            <input type="search" placeholder="search.." />
            <ul class="suggestions">
                <li><a href="What is palliative  care.html">What is palliative ca...</a></li>
                <li><a href="Who needs palliative care.html">Who needs palliative ca...</a></li>
                <li><a href="Talking about palliative care.html">Talking about palliative ca...</a></li>
                <li><a href="How to interact with providers.html">how to interact with providers...</a></li>
                <li><a href="Resources">Resourc...</a></li>
            </ul>
        </form>
    </div>
</section>

I'm seeking assistance with making the search bar function without having to delve into PHP or database creation; any help would be greatly appreciated.

Answer №1

If I understand correctly, you are looking to display content from your suggestions on your page. In that case, here is a suggestion:

<section class="searcharea">
<div class="wrapper">
        <form class="searchbox" action="Resources.html" target="_NEW" action="get">
            <select id="page" placeholder="search.." />
                    <option value="What is palliative  care.html">What is palliative ca...</option>
                    <option value="Who needs palliative care.html">Who needs palliative ca...</option>
                    <option value="Talking about palliative care.html">Talking about palliative ca...</option><option value="How to interact with providers.html">how to interact with providers...</option>
                    <option value="Resources">Resourc...</option>
            </select>
        </form>
    </div>
</section>

For the Resources page, I recommend using PHP as it is a straightforward piece of code. If you prefer not to use server-side scripting, you can potentially retrieve GET parameters with JavaScript as well, but with PHP, you can simply do:

<?php
     header( 'Location: '.$_GET['page'].' ) ;
?>

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

How come pagination links in Vue.js 2 return JSON when clicked?

My question relates to having 2 specific components: Firstly, there is a component called SearchResultVue.vue. The structure of this component is as follows : <template> ... <span class="pull-right" v-show="totalall>8"> ...

Unable to make a post using vue.js

I am facing an issue while trying to submit form data using "vue-resource" in my code. The error message I receive mentions a problem with the use of this method alongside vue-cli and vuetify. Error [Vue warn]: Error in v-on handler: "TypeError: this.$h ...

Utilizing the dnd library to incorporate drag and drop functionality

I've encountered an issue with the code snippet below. Although I am able to drag elements, I am unable to drop them. How can I trigger the dropFunction when a drop occurs? Drag code: <div> <a class="button" ng-class= ...

Effortlessly move and place items across different browser windows or tabs

Created a code snippet for enabling drag and drop functionality of elements within the same window, which is working smoothly. var currentDragElement = null; var draggableElements = document.querySelectorAll('[draggable="true"]'); [].forEach ...

Tips for creating an Enumerable 'similarity' search using linq.js

I have a JSON array that looks like this: [ { "_Id": "0001", "_PatentId": "0000", "_Text": "Employee", "_Value": "employee", "_PermissionLevel": 55 }, { "_Id": "0002", "_PatentId": "0000", "_Text": "Employees" ...

Display the PrimeFaces dialog in the middle of the screen

I've encountered an issue with positioning dialogs on different pages. I tried using a CSS code to center them on the screen, but it didn't work as expected. .ui-dialog{ position: fixed; top: 50%; left: 50%; margin-top: -50px; ...

Changing the cursor to a waiting state following a mouse click

Looking for some help here - when I click a button, the cursor remains standard and doesn't show loading. Any suggestions on how to fix this? Below is the snippet of my code: <div class="signup"> <input type="submit" value="Sign Up" tit ...

Heroku deployment failed: Push rejected due to lack of a Cedar-supported application

Trying to deploy my 3D game (created with three.js) on a Heroku server has brought up an issue. After running the command "git push heroku master," I encountered the following problem: Initializing repository, done. Counting objects: 252, done. Delta com ...

Is the key to achieving optimal client interactions within a client layout, while still maintaining its role as a server component, truly possible?

My current challenge involves managing modals opening and closing with server components instead of client components. In the past, I used to lift the state up to my Layout for client components: export default function Layout({ children }) { const [showP ...

Suspend features for moving between pages in history

In the application, we have two main pages - Home.vue and Statistics.vue. The Home.vue page renders the TableFields.vue component. On the Home page, there are fields with numbers that have an initial value of "3" set upon page load. An interval running a c ...

Bringing Vue Components Together in Laravel: A Guide to Component Importation

Recently, I started learning Vue.js and I am looking to understand how to use component. Unfortunately, when I attempted to import my component into another component, it didn't work as expected. The framework I am currently using is Laravel 5.8 and I ...

Make sure to always display the browser scrollbar in order to avoid any sudden page

Question: How can I ensure the scrollbar is always visible in a browser using JavaScript? I've noticed that some of my web pages have a scrollbar while others do not, causing the page to jump when navigating between them. Is there a way to make t ...

What is the best way to organize angularjs controllers and directives within one another?

When I structure my controllers like this: <body ng-app="app" ng-controller="ctrl"> <div ng-controller="app-get"> <app-get></app-get> </div> <div ng-controller="app-post"> <app-post">& ...

What is the best way to fetch data before a component is rendered on the screen?

I am facing an issue with fetching data from a local server in Node. When I try to render the component, the array 'users' from the state appears to be empty, resulting in no users being displayed on the screen as intended. What's strange is ...

Can you explain the variance in these code snippets when implementing React's setState() function?

Can you explain the variance between these two blocks of code? this.setState((state)=>({ posts: state.posts.filter(post=> post.id !==postRemoved.id) })) versus this.setState((state)=>{ posts: state.post ...

Can Javascript be used to identify the number of td elements in a table and specify column widths within the table tags?

Is there a way to automatically add the "col width" tag based on the number of td tags within a Table tag? For example, if there are 2 td's, then it should add 2 "col width", and if there are 3 then, 3 "col width", and so on. <!DOCTYPE html> &l ...

Extract image file name and date information (day, month, year) from an HTML form using Angular

The content of the register.component.ts file can be found below: import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-register', templateUrl: './register.component.html', styleUrls: [&apo ...

Using window.open and appending a new feature to it

Below is the code found in my index.html file: <!DOCTYPE html> <html> <head> <script> function createDialogBox() { var dialogBox = window.open("in1.html"); dialogBox.nameBox= "my little box" } window.onload = createDialogBox; wind ...

Eliminate a targeted class from an HTML string in PHP

I am dealing with a string that looks like this: $string = '<img class="img-responsive animate scale animated" src="image/catalog/blocks/about-banner.jpg" alt="">'; My goal is to delete the img-responsive class from it. Any suggestions o ...

Ensure at least one checkbox is selected by using jQuery validation

I wrote the code below to select multiple checkboxes and validate that at least one checkbox is selected. The data submission to the database works if I remove onsubmit="return validate_form()". However, I want to ensure that at least one checkbox is selec ...