andrew7667
06-09-2006, 04:30 PM
I'm currently trying to make a "search" feature that when a user inputs some data, it returns the best match.
To be specific, I work for a scale company and am redesigning their entire web page. One of the things I'd like to put in is a search that when you put in answers to a few questions, it tells you which scale would best suit your need.
Now...I'm stuck because I don't know how to return integers in HTML DOM. I have to have the user input some sort of text then use Javascript and some crafty if statements to tell the user what to buy.
This is what I have so far (I'm just trying to get the basic thing working):
<html>
<head>
<script type="text/javascript">
<!--
function search(kind, cap, rez, pri, leg)
{
if(kind=="count")
{
if(cap<=10&&resolution<=.01)
document.write("You need <a href="http://www.google.com" target="main">this</a> kind of scale")
}
}
function check()
{
var kind=document.getElementById("type")
var cap=document.getElementById("capacity")
var rez=document.getElementById("res")
var pri=document.getElementById("price")
var leg=document.getElementById("legal")
if(kind==""||cap==""||rez==""||pri==""||leg=="")
alert(You did not fill everything in!)
else
search(kind, cap, rez, pri, leg)
}
-->
</script>
</head>
<body>
<p>What kind of scale do you need?:</p>
<form>
<input type="radio" name="f" id="type" value="count">Counting Scale<br />
<input type="radio" name="f" id="type" value="floor">Floor Scale<br />
<input type="radio" name="f" id="type" value="genind">General Industrial<br />
<input type="radio" name="f" id="type" value="truck">Truck Scale<br />
<input type="radio" name="f" id="type" value="lift">Forklift Scale<br />
<input type="radio" name="f" id="type" value="parcel">Parcel Scale<br />
<input type="radio" name="f" id="type" value="anim">Animal Scale<br />
<input type="radio" name="f" id="type" value="motion">Weigh in Motion<br />
<input type="radio" name="f" id="type" value="other">Other<br />
<br>
What capacity do you need? (in pounds): <input type="text" id="capacity" onclick="check(this.value)" size=13>
<br>
<br>
What resolution do you need? (in pounds): <input type="text" id="res" onclick="check(this.value" size=13>
<br>
<br>
What is your price range?:<input type="text" id="price" size=13>
<br>
<p>Should the scale be legal for trade?:</p>
<input type="radio" id="legal" name="l" value="yes">Yes<br />
<input type="radio" id="legal" name="l" value="no">No<br />
<br>
<br>
<input type="submit" value="Submit" onclick="check()">
</form>
<br>
</body>
<br />
</html>
Any help would be greatly appreciated, thanks!
To be specific, I work for a scale company and am redesigning their entire web page. One of the things I'd like to put in is a search that when you put in answers to a few questions, it tells you which scale would best suit your need.
Now...I'm stuck because I don't know how to return integers in HTML DOM. I have to have the user input some sort of text then use Javascript and some crafty if statements to tell the user what to buy.
This is what I have so far (I'm just trying to get the basic thing working):
<html>
<head>
<script type="text/javascript">
<!--
function search(kind, cap, rez, pri, leg)
{
if(kind=="count")
{
if(cap<=10&&resolution<=.01)
document.write("You need <a href="http://www.google.com" target="main">this</a> kind of scale")
}
}
function check()
{
var kind=document.getElementById("type")
var cap=document.getElementById("capacity")
var rez=document.getElementById("res")
var pri=document.getElementById("price")
var leg=document.getElementById("legal")
if(kind==""||cap==""||rez==""||pri==""||leg=="")
alert(You did not fill everything in!)
else
search(kind, cap, rez, pri, leg)
}
-->
</script>
</head>
<body>
<p>What kind of scale do you need?:</p>
<form>
<input type="radio" name="f" id="type" value="count">Counting Scale<br />
<input type="radio" name="f" id="type" value="floor">Floor Scale<br />
<input type="radio" name="f" id="type" value="genind">General Industrial<br />
<input type="radio" name="f" id="type" value="truck">Truck Scale<br />
<input type="radio" name="f" id="type" value="lift">Forklift Scale<br />
<input type="radio" name="f" id="type" value="parcel">Parcel Scale<br />
<input type="radio" name="f" id="type" value="anim">Animal Scale<br />
<input type="radio" name="f" id="type" value="motion">Weigh in Motion<br />
<input type="radio" name="f" id="type" value="other">Other<br />
<br>
What capacity do you need? (in pounds): <input type="text" id="capacity" onclick="check(this.value)" size=13>
<br>
<br>
What resolution do you need? (in pounds): <input type="text" id="res" onclick="check(this.value" size=13>
<br>
<br>
What is your price range?:<input type="text" id="price" size=13>
<br>
<p>Should the scale be legal for trade?:</p>
<input type="radio" id="legal" name="l" value="yes">Yes<br />
<input type="radio" id="legal" name="l" value="no">No<br />
<br>
<br>
<input type="submit" value="Submit" onclick="check()">
</form>
<br>
</body>
<br />
</html>
Any help would be greatly appreciated, thanks!