Click to See Complete Forum and Search --> : HTML DOM Issue


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!

the tree
06-10-2006, 03:17 AM
You don't seriously think that doing this in Javascript is scalable do you?

felgall
06-10-2006, 03:24 AM
var kind=Number(document.getElementById("type").value);

kiwibrit
06-10-2006, 04:16 AM
I'd do this in php, using a MySQL database (though I guess you could use a flat file). Firstly, php and MySQL are well set up to do the job. Of course, there are other sound server side solutions. The result will be accessible to pretty much all web users, whereas 20% of web users (including Blackberrys, I'm told) do not have javascript activated.

In the UK, a user who cannot use javascript would have grounds for complaint against you under the Disability Discrimination Act, IMV, if you had a search facility based on javascript.

andrew7667
06-10-2006, 11:56 AM
I've never done anything in either of those. I wouldn't know where to even begin...