Forum Moderators: phranque
I was just wondering if anybody can help me out. I have an html webform that takes orders on my website.
I was just wondering if there is anyway to call out if statements from this webform.
For example if somebody were to type in the SKU of a product in the sku field of the form and the price of that SKU would automatically appear in the Price field of the web form.
Is there anyway this can be done via Javascript or php? Right now my form is actually in HTML however the action script file it's calling is a php file.
Anyhelp is appreciated.
Thanks in advance.
SO, if a person loads a page, and they make their first selection, you can read their chnge, and do something.
If they don't do something on the screen, it won't cause the event to fire. And if they submit, you won't get the results intended.
I ran into this for a similar situation. I had a list of contests and the values of the drop down list were contestname:contestdate:deadline (with the colons)
As they changed the list to their contest, it would read the new value, and parse the three parts so I could check the deadline date against today using a client-side javascript. It worked fine for a while, until people starting just clicking the back button with that contest already loaded and not "changed to".
So many late entries were made.
I changed it to a server side process so that the value is only the ID number of the contest. When they submit, before any processing takes place I do a query of that contest ID and get the deadline date, then compre it to today, and if late, don't make the entry. It takes a little longer (a round trip to the server and an extra query) but my results are much more accurate.
Client Side javascript is good, but not foolproof. And there are a lot of fools out there.