View Full Version : Search within the html pages
I need help to create a search option on my index page ..
I actually have more than 2000 HTML pages on my site ... each page contains details of different applications
the url of HTML pages are like
http://mydomain.com/application1.html?productType=app&Code=1234&version=1.1
http://mydomain.com/application1.html?productType=app&Code=1234&version=1.2
http://mydomain.com/application2.html?productType=app&Code=3456&version=2.0
http://mydomain.com/application2.html?productType=app&Code=3456&version=2.1
as the above HTML page urls have application code as well as versions
I want if there is any code or script which when user input the code like above url code=1234 and the user will be redirected to the page containing the code as well as higher version ...
like the code here for search
<form action="/test.html" method="get">
<input type="text" name="Code" value=""/><br/>
<input type="submit" value="GET IT"/>
</form>
I really appreciate your help
developerhusain
06-02-2013, 05:38 PM
You need to use server side scripting like php to do it. Here is the code.
<? if ($_POST ['get_it']) {
echo "<script language='javascript'>window.location='yoururl.html?code=".$_POST ['Code']."'</script>";
} ?>
<form method="post">
<input type="text" name="Code" value="<?=$_REQUEST ['code'] ?>"><br/>
<input type="submit" value="GET IT" name="get_it">
</form>
Any problem do revert to me
regards
developer husain
thanks for your reply .. sorry to say actually i am not coder .. so it is bit diificult for me understand ..
please help me how to use the given code
but I have all html files only
developerhusain
06-03-2013, 06:23 AM
You said that in your earlier post that when you submit the code,it should redirect to page displaying code as well as higher version.What you do is open a file test.html and put the above code in it.
<? if ($_POST ['get_it']) {
echo "<script language='javascript'>window.location='test.html?code=".$_POST ['Code']."'</script>";
} ?>
<form method="post">
<input type="text" name="Code" value="<?=$_REQUEST ['code'] ?>"><br/>
<input type="submit" value="GET IT" name="get_it">
</form>
What this form will do is when you submit the code it will redirect to same page and display the inputted code in the input field Code. And regarding displaying higher version associated with this code. Doing it in php mysql database can be really useful. If you don't want to do it in mysql database you can do like this to fetch the code as well as higher version
<?
if ($_REQUEST ['Code']=="1234") $higher_version="2.1";
if ($_REQUEST ['Code']=="346") $higher_version="1.1";
echo $higher_version." ".$_REQUEST ['code'];
?>
With this you can achieve what you want. If i have done anything which is contradicting your request.Please do write down your full request. I will definitely help you achieve what you want
I really get frustrated .. I put the above code in between the body tag of test.html .. the result is as in picture shown ..
I don't use any database .. I have created only html pages linked to one another ... Please help
5076
need desperate proper help
developerhusain
06-04-2013, 06:45 AM
You should put this page in .php code. Miss Janu. .html does not help you in being dynamic in your website. I have myself developed a website which is down now in .htm page using frames.You can't do anything dynamic.The above given code will not work in html. It can only be used in php page.
Here is another code much easier for you.This has been tried and tested in php page.This will definitely serve your purpose if you put this in .php page
<form action="test.php?code=<?=$_POST['Code'] ?>" method="get">
<input type="text" name="Code" value="<?=$_REQUEST['Code'] ?>"/><br/>
<input type="text" name="Version" value="<?
if ($_REQUEST ['Code']=="1234") echo "1.1";
else if ($_REQUEST ['Code']=="3234") echo "2.1";
?>"/><br/>
<input type="submit" value="GET IT"/>
</form>
Any other request. you can tell me i'm ready to help you
Regards
developerahusain
jscheuer1
06-04-2013, 07:10 AM
Please use the forum's bbcode tags to make posts more readable:
for php code............
<?php /* code goes here */ ?>
for html...............
<!-- markup goes here -->.....
for js/css/other.......
code goes here................
I and other moderators have been doing this for you. But you've been around awhile now, so please start using proper formatting for code when posting.
Ok Sir, I will do as suggested .. waiting for postie help
developerhusain
06-04-2013, 10:57 AM
Try the code in php page as i have said miss janu. If not i will provide you with javascript for achieving the task.Any problem do revert because i have done lot of coding like this
regards
developerhusain
sorry I came online after few days .. thanks for your kindness .. please help me in any ways to achieve this ...
developerhusain
06-09-2013, 11:26 AM
I will direct you to do this.Put the above code in .html page itself. Open your desktop explorer and rename the test.html to test.php.Just rename the extension from .html to .php. This would work for you.
regards
developerhusain
need desperate help to achieve my purpose plz
developerhusain
06-12-2013, 04:30 AM
Here is the javascript way to achieve what you want. It can work in .html page as you wanted.I don't know how many codes you have with you so i have readied a script consisting of five codes with its versions.
1234 1.1
1235 1.2
1236 1.3
2345 2.1
You can insert as many codes with its version just like as i did below.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
function optionCheck() {
var option = document.getElementById("options").value;
if(option == "1234"){document.getElementById("input1").value ="1.1"; }
if(option == "1235"){ document.getElementById("input1").value ="1.2"; }
if(option == "1236"){ document.getElementById("input1").value ="1.3"; }
if(option == "2345"){ document.getElementById("input1").value ="2.1"; }
}
</script>
</head>
<body>
<form name="asd" method="post">
<table width="500" cellpadding="0" cellspacing="0" class="style11">
<tr><td>Code:<input type="text" name="code" id="options"></td></tr>
<tr><td>Version:<input type="text" name="input1" id="input1"></td></tr>
<tr><td><input type="button" name="as" onClick="optionCheck()" value="submit"></td></tr>
</table>
</form>
</body>
</html>
i think this method is too difficult to write individually each version and code .. whereas i have almost 30,000 versions
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.