PDA

View Full Version : Help Coding Additional Money Function(s) in html form

allmaxedout
11-14-2011, 09:03 PM
I am new to programming and am working partially with already existing code.

student = document.form1.J1Registration[2].checked || document.form1.J1Registration[3].checked || document.form1.J1Registration[7].checked || document.form1.J1Registration[8].checked || document.form1.J1Registration[9].checked;
if (student !=true){
notaken = 0;
if (document.form1.L1PREConvWSAM[0].checked){notaken = notaken + 1};
if (document.form1.L1PREConvWSAM[1].checked){notaken = notaken + 1};
if (document.form1.L1PREConvWSAM[2].checked){notaken = notaken + 1};
if (document.form1.L2PREConvWSPM[0].checked){notaken = notaken + 1};
if (document.form1.L2PREConvWSPM[1].checked){notaken = notaken + 1};
if (document.form1.L2PREConvWSPM[2].checked){notaken = notaken + 1};
//if (document.form1.L1PREConvWS[0].checked){money = 30 + money};
//if (document.form1.L2PREConvWS[1].checked){money = 30 + money};}
if (notaken == 1){money = 40 + money};
if (notaken == 2){money = 70 + money};
}

I want to be able to charge a different dollar amount when student !=false. Instead of charging all students \$0, I want to be able to charge them \$10 and \$15 respectively and everyone else will pay the \$40 and \$70 already coded. Any help is greatly appreciated! Additional questions are also welcome as I am certain I am using the wrong lingo.

sunfighter
11-15-2011, 03:59 PM
This is not HTML nor CSS, it's javascript. And there is a hellacious amount of code missing.

Put the entire code up and we'll give it a go.

allmaxedout
11-15-2011, 04:18 PM
Thanks Sunfighter and you are right there is a tremendous amount missing. I thought I was providing what was needed instead of including a lot of unneeded jibbirish. I am also not familiar at all with the coding jargon. I was told this was html....I thought javascript was for interactive elements so I didn't question it when they said html. I had to remove some of the insignificant field data from this and send it in 2 parts as it went over the character limit for the post. If you need something you suspect I removed, let me know. Here you go and thanks for taking the plunge:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script><!--
function totalmoney(fieldObject) {
money = 0;
if (document.form1.J1Registration[0].checked) { money = 195 + money};
if (document.form1.J1Registration[1].checked) { money = 220 + money};
if (document.form1.J1Registration[2].checked) { money = 60 + money};
if (document.form1.J1Registration[3].checked) { money = 75 + money};
if (document.form1.J1Registration[4].checked) { money = 75 + money};
if (document.form1.J1Registration[5].checked) { money = 315 + money};
if (document.form1.J1Registration[6].checked) { money = 340 + money};
if (document.form1.J1Registration[7].checked) { money = 90 + money};
if (document.form1.J1Registration[8].checked) { money = 105 + money};
if (document.form1.J1Registration[9].checked) { money = 100 + money};

if (document.form1.J2Registration[0].checked) { money = 90 + money};
if (document.form1.J2Registration[1].checked) { money = 90 + money};

//if (document.form1.PREConv1GROSS.checked) {
// if ((document.form1.J1Registration[2].checked) || (document.form1.J1Registration[3].checked) || (document.form1.J1Registration[10].checked))
// {money = 0 + money}
// else
// {money = 15 + money}
// }
// if (document.form1.PREConv2WILLIAMS.checked) {
// if ((document.form1.J1Registration[2].checked) || (document.form1.J1Registration[3].checked))
// {money = 0 + money}
// else
// {money = 40 + money}
// }
//if (document.form1.PREConv3BGATBAGAR.checked) {
// if ((document.form1.J1Registration[2].checked) || (document.form1.J1Registration[3].checked))
// {money = 0 + money}
// else
// {money = 40 + money}
// }

if (document.form1.K1ASHACEU.checked) { money = 10 + money};
if (document.form1.K3AAACEU.checked) { money = 10 + money};
if (document.form1.K5ABATier1.checked) { money = 10 + money};
if (document.form1.K6CECERT.checked) { money = 10 + money};
if (document.form1.H7BoxedLunch.checked){ money = 16 + money};

precnt = 0;
//if (document.form1.PREConv1LEEWHITE.checked) { precnt++};
//if (document.form1.PREConv2GARNNUNN.checked) { precnt++};
//if (document.form1.PREConv3STAUGLER.checked) { precnt++};
//if (document.form1.PREConv4MASTERSON.checked) { precnt++};

//if (precnt == 2) {money = 70 + money};
//if (precnt == 1) {money = 40 + money};
// document.form1.PREConv1LEEWHITE.checked = false;
// document.form1.PREConv2GARNNUNN.checked = false;
// document.form1.PREConv3STAUGLER.checked = false;
// document.form1.PREConv4MASTERSON.checked = false;
// };//if greater then 2

student = document.form1.J1Registration[2].checked || document.form1.J1Registration[3].checked || document.form1.J1Registration[7].checked || document.form1.J1Registration[8].checked;
if (student !=true){
notaken = 0;
if (document.form1.L1PREConvWSAM[0].checked){notaken = notaken + 1};
if (document.form1.L1PREConvWSAM[1].checked){notaken = notaken + 1};
if (document.form1.L1PREConvWSAM[2].checked){notaken = notaken + 1};
if (document.form1.L2PREConvWSPM[0].checked){notaken = notaken + 1};
if (document.form1.L2PREConvWSPM[1].checked){notaken = notaken + 1};
if (document.form1.L2PREConvWSPM[2].checked){notaken = notaken + 1};
//if (document.form1.L1PREConvWS[0].checked){money = 30 + money};
//if (document.form1.L2PREConvWS[1].checked){money = 30 + money};}
if (notaken == 1){money = 40 + money};
if (notaken == 2){money = 70 + money};
}

document.form1.Total.value = money;

}
function SetRedirect(){

document.form1.redirect.value='ProcessPayPal.php?

var keys = document.all?true:false;
function keyHandler(e) {
var _ret=true;
var _char=keys?event.keyCode:e.which;
if(_char==13)
_ret=false;
return _ret;
}

}
\$("form input[@type=text]").bind("keypress", function(e) {
var code=e.charCode || e.keyCode;
return (code==13)?false:true;
})

// -->
</script>
<style type="text/css">
<!--
-->
</style>

<body bgcolor="#FFFFFF" background="images/bkg_slice.jpg">

<table align="center" width="1048" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<tr>
<td height="12"></td>
<td></td>
<td></td>
</tr>
<tr valign="top">
<td width="314"><a href="index.htm"><img src="images/logo.png" border="0" height="88" width="314" /></a></td> <td align="right" valign="middle" width="510"><form action="search.asp" id="form2" name="form2" method="post"><input type="text" name="txtSearch" id="txtSearch"><input type="submit" name="search" value="search"></form>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
</td>
</tr>
</table>

<table align="center" width="1048" border="0" cellspacing="0" cellpadding="0">
<tr><td background="images/footer_bot2.png" height="22"></td></tr>
<tr>
<td background="images/main_bkg.png"><table align="center" width="1024" border="0" cellspacing="0" cellpadding="0">

<tr>
<td colspan="5">&nbsp;</td>
</tr>
<tr valign="top">
<td width="2"></td>
<td width="19">&nbsp; </td>

<td width="898">

<form method="POST" action="gdform.php" id="form1" name="form1" >
<input type="hidden" id="redirect" name="redirect" value=""><input type="hidden" value="Convention_PreRegistration" name="A1">
<table width="100%" height="6178" border="3" cellpadding="6" cellspacing="3" bordercolorlight="#bea376" bordercolordark="#93671e">
<tr>
<td colspan="2" style="background-color: #039;"><div align="center"><font color="#ffffff" size="4" face="Arial, Helvetica, sans-serif"><b style="">Online Convention Pre-Registration Form</b></font><span style="text-align: center"></span></div></td>
</tr>

<br />
<strong>OSLHA Members:
<br />
<br>
</strong>
<input name="J1Registration" type="radio" tabindex="16" onclick="totalmoney(this)" value="MBRReg-Before2-1" />
Member - <span style="font-size: 9pt; font-style: italic;">by February 1, 2012 **</span>&nbsp;
- \$195.00<br>
&nbsp; <br>
<input type="radio" name="J1Registration" value="MBRReg-after2-1" onClick="totalmoney(this)" />
Member -<span style="font-size: 9pt; font-style: italic;"> after February 1, 2012**</span> -

\$220.00 <br>
<br>
<input type="radio" name="J1Registration" value="MBRStudent-before2-1" onClick="totalmoney(this)" />
Full-Time Student Member - <span style="font-size: 9pt; font-style: italic;">by February 1, 2012 </span> -

\$60.00 <br>
<br>
<input type="radio" name="J1Registration" value="MBRStudent-after2-1" onClick="totalmoney(this)" />
Full-Time Student Member - <span style="font-size: 9pt; font-style: italic;">after February 1, 2012</span> -

\$75.00 <br>
<br>
Consumer / Parent Member -

\$75.00

<br>
</p>
<p align="left"><strong>OSLHA Non-Members:</strong> <br />
<span style="font-size: 9pt">Non-Members are invited to join OSLHA prior to
registering for convention and benefit from Member convention rates.<br />
<p align="left"><input type="radio" name="J1Registration" value="NonMBRbefore2-1" onClick="totalmoney(this)" />

Non-Member - <span style="font-size: 9pt; font-style: italic;">by February 1, 2012 </span> -
\$315.00 <br>
<br>
<input type="radio" name="J1Registration" value="NonMBR-after2-1" onClick="totalmoney(this)" />
Non-Member - <span style="font-size: 9pt; font-style: italic;">after February 1, 2012</span> -

\$340.00 <br>
<br>
<input type="radio" name="J1Registration" value="StudentNonMBR-before2-1" onClick="totalmoney(this)" />
Non-Member Full-Time Student - <span style="font-size: 9pt; font-style: italic;">by February 1, 2012 </span> -

\$90.00 <br>
<br>
<input type="radio" name="J1Registration" value="StudentNonMBR-after2-1" onClick="totalmoney(this)" />
Non-Member Full-Time Student - <span style="font-size: 9pt; font-style: italic;">after February 1, 2012</span> -

\$105.00 <br>
<br>
Non-Member Consumer/Parent -

\$100.00
<br>
<br>
<strong class="section">Invite a Spouse / Guest:</strong><br />
<br />
<input name="J2Registration" type="radio" tabindex="17" onclick="totalmoney(this)" value="Spouse/Guest" />
Spouse / Guest (not
in
profession) ***&nbsp;-

\$90.00
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="J2Registration" value="Spouse/Guest" onclick="totalmoney(this)" />
Spouse / Guest Name:
<input type="text" name="J2Spouse/GuestName" size="26" onclick="totalmoney(this)" id="J2Spouse/GuestName" />
<p align="left"><strong>OSLHA Invited Participants:</strong><br />
<br />
Outstanding Students and Scholarship Nominees or Student Leadership Program Participant
<p align="left">
Exhibit Booth Staff Member

<blockquote>
<p align="left">Exhibitor Company Name:
<input name="1Registration" type="text" id="1Registration2" tabindex="20" onclick="totalmoney(this)" size="40" />
</p>
</blockquote>
<p align="left"><em style="font-size: 9px">( <span style="font-size: 9pt">If you do not make any additional purchases in this transaction, you will be prompted to &quot;Continue&quot; to payment at the end of this form. Please do so to submit your form but when you arrive at the next page you may close out of it and your form will be submitted without a payment. )</span></em><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
<span style="font-size: 10pt">**&nbsp;&nbsp; Member rate for members of the Ohio Academy of Audiology
(OAA), or members of adjacent state associations (Indiana, Kentucky,
Michigan, Pennsylvania and West Virginia), or members of the Ohio
Hearing Aid Dealers Assoc.&nbsp; Must submit copy of membership card with registration and note your state affiliation in the notes/comments section please.<br />
<br />
***&nbsp; The Fee for Spouse/Guest will allow them to attend
all Convention activities including Sessions, Exhibits and Special
</tr>
<tr>
<td colspan="2" align="left" style="background-color: #039;"><div align="center"><font color="#ffffff" size="4" face="Arial, Helvetica, sans-serif"><b>PRE-Convention Clinical / Research Symposiums (Thursday) :</b></font></div></td>
</tr>
<tr>
<td height="146" colspan="2" align="center" bgcolor="#980e0b" style="background-color: #FFF;"><div align="left">
<p>Choose up to (2) desired selections<strong><br />
</strong></p>
<p align="center"><strong> Registrant Cost</strong>:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<strong>Student Cost: </strong> <br />
Attend <strong>1 Symposium</strong> AM or PM / \$40 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Attend <strong>1 Symposium</strong> AM or PM / \$10 <br />
OR Attend <strong>2 Symposiums</strong> AM &amp; PM / \$70&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OR Attend <strong>2 Symposiums</strong> AM &amp; PM / \$15<br />
<br />
</p>
</div></td>
</tr>
<tr>
<td height="278" colspan="2" align="center" bgcolor="#980e0b" style="background-color: #FFF;"><p align="left"><strong>Thursday, March 8, 2012<br />
</strong><span style="font-weight: bold">8:30 a.m. - 12:15 p.m</span>&nbsp;&nbsp;</p>
<p align="left"><i><span style="font-weight: bold">
<input name="L1PREConvWSAM" type="radio" tabindex="21" onclick="totalmoney(this)" value="Pre#1" />
</span></i><span style="font-weight: bold"> Language &amp; Literacy Symposium : Part 1&nbsp;</span>&nbsp;&nbsp;&nbsp;<br />
New Ohio Common Core Standards/ Model Curriculum in English Language Arts: Impact on School SLP's <em>by <strong>Susan Givler</strong> </em>&amp; <br />
SLP's &amp; RTI: Supporting Core Curricular Standards <em>by <strong>Sandra Gillam</strong></em></p>
<p align="left"><i>
<input type="radio" name="L1PREConvWSAM" value="Pre#2" onclick="totalmoney(this)" />
</i> <span style="font-weight: bold">Special Populations Symposium : Part 1&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;<br />
International Adoptees: Who Are They, How Do They Communicate and What Can We Do to Facilitate Age Appropriate Skills <em>by <strong>Christina Doelling</strong></em> &amp; Hanen Programs: A Mediator Model for Early Language Intervention <em>by <strong>Toby Stephan</strong></em></p>
<p align="left"><i>
<input type="radio" name="L1PREConvWSAM" value="Pre#3" onclick="totalmoney(this)" />
</i> <span style="font-weight: bold">Follow the Swallow: Swallowing Issues Across the Lifespan Symposium: Part 1&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;<br />
Infant Feeding <em>by <strong>Amy Thorpe</strong></em> &amp; Transition From Feeding to Speech <em>by <strong>Marsha Lee-White</strong></em></p></td>
</tr>
<tr>
<td height="295" colspan="2" align="center" bgcolor="#980e0b" style="background-color: #FFF;"><p align="left"><strong>Thursday, March 8, 2012<br />
</strong><span style="font-weight: bold">1:15 p.m. - 5:00 p.m</span>&nbsp;&nbsp;</p>
<p align="left"><i>
<input name="L2PREConvWSPM" type="radio" tabindex="22" onclick="totalmoney(this)" value="Pre#4" />
</i><span style="font-weight: bold">Language &amp; Literacy Symposium : Part 2&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
Language &amp; Literacy Development for Children with ASD: Linking Research and Practice <span style="font-style: italic">by <strong>Christina Yeager Pelatti </strong>&amp; Effective Literacy Interventions for Students with Autism Spectrum Disorders by <strong>Sandra Grether</strong></span></p>
<p align="left"><i>
<input type="radio" name="L2PREConvWSPM" value="Pre#5" onclick="totalmoney(this)" />
</i><span style="font-weight: bold">Special Populations Symposium : Part 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;<br />
Applying &quot;Social Thinking&quot; Tenants to the Treatment of Adolescents with Language and Emotional Impairments <em>by <strong>Christine Lackey &amp; Dawn Girten</strong></em> &amp; Developing Successful Interventions for Students with Fetal Alcohol Syndrome <em>by</em> <strong><em>Janice Wright</em></strong></p>
<p align="left"><i>
<input type="radio" name="L2PREConvWSPM" value="Pre#6" onclick="totalmoney(this)" />
</i><span style="font-weight: bold">Follow the Swallow: Swallowing Issues Across the Lifespan Symposium : Part 2 &nbsp;</span>&nbsp;&nbsp;&nbsp;<br />
Swallowing: Sudoku for the SLP <span style="font-style: italic"><em>by <strong>Patricia Fisher</strong></em></span> &amp; Adult Swallowing Issues<em> by <strong>Mary Casper</strong></em></p></td>
</tr>
<tr>
<td colspan="2" align="left" style="background-color: #039;"><div align="center"><font color="#ffffff" size="4" face="Arial, Helvetica, sans-serif"><b>Short Courses (Friday &amp; Saturday) :</b></font></div></td>
</tr>
<tr>

allmaxedout
11-15-2011, 04:18 PM
<td colspan="2" align="left" style="font-size: 10pt"><p>CEUs/Contact Hours are available for
all PRE-Convention Workshops, Short Courses, Double Miniseminars, Miniseminars, Caucuses and up to (6) Poster Sessions.</p>
<p>Choose ALL that Apply:</p></td>
</tr>

<td colspan="2" align="center" bgcolor="#980e0b" style="background-color: #039;"><font color="#ffffff" size="4" face="Arial, Helvetica, sans-serif"><b>Make a Scholarship Fund Donation:</b></font></td>
</tr>
<tr>
<td height="33" align="center" colspan="2">\$
<input name="M1ScholarshipDonationAmt" type="text" id="M1ScholarshipDonationAmt" tabindex="51" onchange="totalmoney(this)" size="6"></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#980e0b" style="background-color: #039;"><font color="#ffffff" size="4" face="Arial, Helvetica, sans-serif"><b>Total Amount Due:</b></font></td>
</tr>
<tr>

<tr>
<td colspan="2" align="center" bgcolor="#980e0b" style="background-color: #039;"><font color="#ffffff" size="4" face="Arial, Helvetica, sans-serif"><b>Comments &amp; Notes:</b></font></td>
</tr>
<tr>

<tr>
<td colspan="2" align="center" style="background-color: #039;"><font color="#ffffff" size="4" face="Arial, Helvetica, sans-serif"><b>Confirm Your Email</b></font></td>
</tr>
<tr>
<td height="91" align="center"> <div align="left">Confirm Your E-Mail:<br />

<span style="font-size: 9pt; font-style: italic;">*You will receive email notification on the following: <br />
and for receipt of CE certificate of attendance</span>.<br />
</div></td>
<td align="center"><span id="sprytextfield3"><span id="sprytextfield1">
<label>
<input type="text" name="text1" id="text1" tabindex="54" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span></span><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td colspan="2" height="335" align="left">
<p>Click
<span style="font-weight: bold; font-size: 14pt;">&quot;Continue&quot;</span> at end of this form to submit your form and to pay your fees via PayPal.
<p align="center"><i><b>Please Note: If you choose to pay with a credit card, you cannot use a card previously used with a Paypal account without logging into Paypal when prompted.</b></i><br />
</p>
<blockquote>
<p align="center"><br />
<input name="Z9" type="submit" tabindex="54" onclick="SetRedirect();" value="Continue" />
<input name="B2" type="reset" tabindex="55" value="Reset" />
<br />
</p>
</a></strong></p>
800.866.OSHA to address questions or concerns.</i></p>
</blockquote>
<p align="center"><br />

<i>Thank
You!</i></p></td>
</tr>
</table>

<p align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p align="center">&nbsp;</p>
</form> </td>

<td width="19">&nbsp; </td>
</tr>
<tr valign="top">
<td width="2"></td>

<td width="19">&nbsp; </td>
<td>&nbsp;</td>
<td width="19">&nbsp; </td>
</tr>
</table></td>
</tr>
<tr>
<td background="images/footer_slice.png"><script type="text/javascript" src="footer.js"></script></td>
</tr>
<tr>
<td height="22" background="images/footer_bot.png"></td>
</tr>
</table>

sunfighter
11-15-2011, 05:29 PM
Just some words of caution.
-----------------------------------
Working with existing code to make a site that deals in money is not the best thing to do IMHO, especially if your new to or don't understand programming.

This (line 8) = <script><!--
the <!-- tells me the code is older then mosses.

A look at the 154 errors in the body (due to using depreciated tags) means a lot of work fixing things up.

You have at lest one error. (Line 87)
is:
document.form1.redirect.value='ProcessPayPal.php?
S/B
document.form1.redirect.value='ProcessPayPal.php';
OR
document.form1.redirect.value='ProcessPayPal.php?'; probably this one.

And part two of the code has 2 </table> that do not have start tags.
----------------------------------------------------------------------------------------------

The code you posted in post 1 does contain what needs to be changed to alter fees.
For full time students change lines 13, 14, 18, and 19.
ex:
line 13
if (document.form1.J1Registration[2].checked) { money = 60 + money};

60 is the amount charged, change to what you want.

allmaxedout
11-15-2011, 09:01 PM
Thanks Sunfighter.
This site already functions with money. I am just want to make a selection in it that was a certain price and different price for people who fit a set of criteria. ie.offer "a discount" for those who live in a certain zip code. Certainly it isn't expected that I would recreate our site from scratch just to add this functionality, right?!
It's Moses
I am not sure why the code would be ancient as this site was just developed by a reputable company 2 years ago.
Not worried about the errors right now, but thanks.
Tried changing line 87 to your suggested code and it breaks the functionality so apparently this code is necessary
thanks for looking at this but a closer look at my origional question would have indiicated that I am wanting to adjust the coding regarding the preconvwsam and preconvwspm radio button selections further down in the code. The section you referred to is our registration rate and that is not going to change. It's the addition of other selections that I need to alter.