Teen Programmers Unite  
 

 

Return to forum top

Help! JAVASCRIPT

Posted by Sinaskape [send private reply] at February 03, 2002, 03:34:07 AM

Hello:

I was wondering, I need to make a program that will give the user a price once they enter a number. I making this for my father's business website, and I was wondering where do I start, this is how I have it set up...

1) the user enters a number
2) if that number matches the number in the "database" then it will give the user a price in the form of a popup.
3) the user will submit all the info through our form

Is that possible? Please help!
-James

Posted by vladimir_l [send private reply] at February 03, 2002, 05:00:31 AM

Ahh, a code ordering system , correct ? JavScript is not really powerful enought to do that , the connectivity with a database cannot be achieved with a server side , but if you use Perl and CGI I am sure you can get the job done much better , if you want to use Java the dtabase will have to be incide the script.

Posted by Sinaskape [send private reply] at February 03, 2002, 01:45:10 PM

Hey VLAD:

Below is kinda what I want (paste into HTML file between body tags)

<SCRIPT>
function compute(obj) {
obj.result.value = eval(obj.expr.value)
}
</SCRIPT>
<FORM NAME="evalform">
Enter an expression: <INPUT TYPE=text NAME="expr" SIZE=20 >
<BR>
Result: <INPUT TYPE=text NAME="result" SIZE=20 >
<BR>
<INPUT TYPE="button" VALUE="Click Me" onClick="compute(this.form)">
</FORM>

Now, this is just the setup, how can I make a list of numbers so when the user types in his number let's say "35" and if that number matches a number in the script data, then it will give the user a result like "$1,000"...Please respond ASAP with any new ideas.

-James

Posted by vladimir_l [send private reply] at February 03, 2002, 03:02:39 PM

Dear James me and Exe have resloved this matter for you from 2 viewpoints , I think you should invent a clever formula invloving a code like rty6 linked with a price , which would be VERY hard becasue there is an infinate amount of prices , he offers a more rational approcach by making something of an array or a hash.

Vlad.

Posted by vladimir_l [send private reply] at February 03, 2002, 03:13:56 PM

not infinate but 100000 for 0 to 10000 dollars.

Posted by CodeRed [send private reply] at February 03, 2002, 07:48:04 PM

This isn't hard, any scripting language that supports databases will be able to do this easily

Posted by vladimir_l [send private reply] at February 04, 2002, 09:59:41 AM

Like PHP , but if he wants to stick with JavaScript it will be mighty hard !

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.