Javascript--complete novice--question I know practically nothing about javascript or html, save what I've learned on the net and from some library books so please be patient with me.
I'm trying to put together a very simple form that will calculate the price of an order of tickets for a local community theater group. Someone suggested javascript since it will manipulate data without using ActiveX.
So, I have made a very basic form which allows one to select a performance date and the number of tickets, and then calculates the price of the tickets.
I have a couple of questions.
First, we have 3 different ticket prices: adult, senior and student. So, right off the bat I have 3 calcultions to make. It's the same procedure each time and the way I have set it up right now, I have a bunch of different function calls for each calculation. This is how it goes for one type of ticket, A standing for adult:
function calcA(){
document.PPFTixOrd.TixAOrd$.value =document.PPFTixOrd.TixANum.value* document.PPFTixOrd.TixA$.value;
}
function FindA(){
doFindA=setInterval("calcA()",1);
}
function xcalcA(){
clearInterval(doFindA);
}
<input type=text name="ALabel" value="Adult" align=left>
<input type=text name="TixANum" align=right size="6" value="" onFocus="FindA();" onBlur="xcalcA();">
<input type=text name="TixA$" readonly="readonly" align=right size="10" value="15";>
<input type=text name="TixAOrd$" align=right size="6" readonly="readonly">
<br>
It all happens twice more--senior and student. I haven't been successful at totalling all the tickets or price yet, but I'm sure I'll get there eventually.
Anyway, question #1 is, is there some way to generically reference an input item so that I could use the same set of functions for all 3 calculations? In Access there is that Me! reference which is very helpful. I hope I'm making sense. What I want to do is pass the value I type in for the adult tickets up to some other variable and do the calculation from there. Then, when I go to the next line, say senior, I can pass that value up to the same variable and do the same calcultion again.
Question 2: Once I get that sorted out, I'm wondering how to pass this information into an Access database. Right now, I have a terrific database which allows me to take ticket orders, reserve seats, etc (for which I've received tremendous help from someone else at this site). I'd like people who want to buy tickets to be able to submit this form to me via email, and from there I would like to transfer the data to Access. This will take a bit of doing for me, but I'm wondering if this is workable. Already I've noticed that I cannot use the copy and paste to even put the data into Excel.
Any advice would be most appreciated. |