I have a search directory and think the Google Calculator script is pretty cool (not sure if Yahoo has one). My thinking is that the device to make a calculator should already be on my server and found some perl links on how to do it, just don't know if this can be integrated into a search box like Google. Anyone done it and is it easy to implement?
From a programming point of view, if you know perl/php etc., it's not that hard. Once the form is submitted and before you output general results, match the submitted strings against typical culculation operators like +, - or search for measurement units like litre, pounds etc. Then do the magic. Not familiar with implementing any existing scripts though but if I were to get someone on Get A Freelancer to do this I'd expect to pay no more than $100.
Do it the easy way and use the google api. You can pass any query to them and output the answer without having to try and copy a script that they have already done.
Thanks guys, useful tips. Found these in regards to what Google made: http://johnbokma.com/perl/google-calculator.html http://fundisom.com/phparadise/php/forms/simple_calculator But yep the problem is implementing it on my Uncover China site. 100 USD? Can anyone do it cheaper here?
Then your code is in plain view for everyone to steal. Mad4's suggestion with the API is probablt easiest indeed.
But since I'm creating a Search Engine, I'd prefer to use my own site rather than keep on using tools from the God that is known as Google.
So misohoni, all you're looking for is a text box that when someone types a number in it, it multiplies the entered number by a conversion factor and then displays that number somewhere?
Here's a small proof of concept. Obviously it's no where near ready for production, but it shows what's possible: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head><title>POC JavaScript Calculator</title></head> <body> <input id="src" type="text" onkeypress="document.getElementById('dest').innerHTML='';document.getElementById('dest').innerHTML=this.value*1.5" onkeyup="document.getElementById('dest').innerHTML=this.value*1.5"> <div id="dest"></div> </body> </html> HTML:
Thanks Tops30 and Marty. Yep looking for someone to code it for me, pretty rubbish at doing it myself. Thanks Marty for the code, I see what you are doing, but want some thing simlar to the Google Calc - http://www.google.com/help/features.html#calculator, so that it recognises +, x, - and division. Just keep on thinking that the code used on the server is capable of calculation, just need to know how to get to it...
Hmmm. Every programming language I know of has built in functions for doing basic math. The tricky part for your project is going to be parsing the "x","+","-" , and "/" out of the string and then forming the appropriate mathematical formulas. I think the person that helps you do this will need to examine every character and the evaluate whether that character is a number, blank space, or command. Then once they've got that they will need to evaluate whether the string makes any sense from a math perspective. If it doesn't make any sense then you don't have an easy fallback like google (they just render search results try 2*2a on google) you need to know exactly how you want to handle errors. I don't know if anyone has submitted a proposal to you for this job, but if no one has it's probably because it's hard to know exactly what you need. These types of requests tend to start off with simple requirements, but then the requirements tend to grow as the customer sees the final product. Good luck misohoni
Thanks. All I'm requesting at the moment is the simple calculator script. My setup is like: <form id="search-form-id" class="v5" name="schina" action="/index.php"> If anyone can do it, please let me know. Thanks
Search calculator on pixel2life .com there are quite a few in javascript, not sure if it's quite what you want though