how to focus on a particular section in another html or php page while clicking a button?

I want to use a search option to find the contents in another page.

My Html page:

<form action="search.php" method="post">
<input name="search" type="text"/> 

<input type="image" src="images/search-btn.jpg" alt="search-btn" /> 
</form>

I have 5 topics in another page, say 'products.html'. Topic headings are Film, Music, etc. So if a keyword, like the headings or some predefined keywords in each topic, is typed and search button is clicked I want to redirect to the products.php page.

The main thing is that i want to get the focus on that particular topic

Now I'm redirecting simply like this:

   <?php
    $val=$_POST['search'];

    if($val=='Music'||$val=='singer')
    {
        header('Location:http://localhost/products.html');
    }

?>

Answers


page1.html

<a name='music'></a><!-- This is anchor -->

<a href='#music'>Go to music on same page</a>

page2.html

<a href='page1.html#music'>Go to music on another page</a>

SERVER SIDE:

<?php
    if($val=='Music'||$val=='singer'){
       header("Location:http://localhost/products#$val.html");
    }
?>

You can style your keywords anchors as you wish:

<a name='music'><b>music<b></a>

<span id='music'>music</span>

Within your form post to a page that can deal with the result, save it and then push the user on.

<form action="process.php" method="post" name="search">

This response page will redirect to something like

header("Location: /products.html#music");

Depending on how the form was completed.

Then on your products page add ids that tie this up, for example:

<h2 id="music">Music</h2>

The user will be redirected and the browser will jump to the corresponding anchor or id.


You can also try this technique by using a hidden field, but for the first page JavaScript will work for this

<input name="target" type="hidden" value=""/> 
<input name="search" type="text" onkeyup="your-function-to-set-value-on-hidden-field"/> 

Set the value if typed keyword is matched with your list and on the second page receive the hidden field value in PHP variable and do the stuff.


Need Your Help

No text index for collection MongoDB

php mongodb full-text-search

I tried to run this simple example to try the example (found on MongoDB Website)on how to use textSearch feauture in Mongo 2.4

nginx/angular/node.js root URL with prerender.io

javascript angularjs node.js nginx url-routing

We have an angular SPA using node, nginx, and prerender.io. Our home page is set as a unique url (i.e. www.foo.com/bar) and in our routing, this home page captures the default redirect of all root-