Thread: calculator
View Single Post
  #5  
Old 02-23-2008, 12:42 AM
StakingAces StakingAces is offline
 
Join Date: Oct 2007
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, here's where we're stuck....

" its f4.value and redoing f2.value after it
they're not adding
the () in them i added to try to calculate
also tried "" and spacing different
those two dont compute just attach "

--------------- Added [DATE]1203738499[/DATE] at [TIME]1203738499[/TIME] ---------------

I dont know, we just can't get it to compute - just mashes all the numbers together.

--------------- Added [DATE]1203742838[/DATE] at [TIME]1203742838[/TIME] ---------------

ok heres the updated code but it still wont add, it just combines - its 99% done but we cant get this...

<html>
<head>
<script type="text/javascript">
<!--

function calculate(task){
var f1 = document.getElementById("stake");
var f2 = document.getElementById("cash");
var f3 = document.getElementById("horseshare");
var f4 = document.getElementById("stakershare");
var f5 = document.getElementById("siteshare");

if(task == "compute")
{
if(isNaN(f1.value) || isNaN(f2.value))
alert("Invalid field entry!");
else
{

f3.value = (f2.value - f1.value)/2;
f5.value = (f3.value)*.05;
f3.value = f3.value - f5.value;

//@%@#% f4.value = f3.value + f1.value;


}
}
if(task == "reset")
{
f1.value = "";
f2.value = "";
f3.value = "";
f4.value = "";
f5.value = "";
}
}
-->
</script>
</head>
<body>
<TABLE width=200 height=100 >
<TR>
<TD >
Amount of stake: <input type="Text" id="stake"></br>

Total Amount Cashed: <input type="text" id="cash">
</br>
<input value="Calculate" type="button" onclick="calculate('compute')"/>
<input type="button" value="Clear Fields" onclick="calculate('reset')"/>
</br></br></br>
Total to be shipped to site: <input type="text" id="siteshare"></br>
Total to be shipped to staker: <input type="text" id="stakershare"></br>
Total to keep: <input type="text" id="horseshare">
</TR>
</TD>



</TABLE>
</body>
</html>

--------------- Added [DATE]1203756324[/DATE] at [TIME]1203756324[/TIME] ---------------

Ok, I think we got it - now heres the noob part lol - can you tell me the exact steps I need to take to try it out on my forum? I want it to be available as a sticky in one forum. Heres the code BTW Hugh....

<html>
<head>
<script type="text/javascript">
<!--

function calculate(task){
var f1 = document.getElementById("stake");
var f2 = document.getElementById("cash");
var f3 = document.getElementById("horseshare");
var f4 = document.getElementById("stakershare");
var f5 = document.getElementById("siteshare");
var f6 = document.getElementById("adjustedhorse");

if(task == "compute")
{
if(isNaN(f1.value) || isNaN(f2.value))
alert("Invalid field entry!");
else
{

f6.value = ((f2.value - f1.value)/2).toFixed(2);
f5.value = ((f6.value)*.05).toFixed(2);
f3.value = ((f6.value - f5.value)).toFixed(2);
f4.value = ((f6.value *1)+(f1.value*1)).toFixed(2);

}
}
if(task == "reset")
{
f1.value = "";
f2.value = "";
f3.value = "";
f4.value = "";
f5.value = "";
}
}
-->
</script>
</head>
<body>
<TABLE width=200 height=100 >
<TR>
<TD >
Amount of stake: <br>$<input type="Text" id="stake"><br>

Total Amount Cashed: <br>$<input type="text" id="cash">
<br>
<input value="Calculate" type="button" onclick="calculate('compute')">
<input type="button" value="Clear Fields" onclick="calculate('reset')">
<br><br><br>
Total to be shipped to site:<br> $<input type="text" id="siteshare"><br>
Total to be shipped to staker:<br> $<input type="text" id="stakershare"><br>
<input type="hidden" id="adjustedhorse">
Total to keep:<br> $<input type="text" id="horseshare">
</TR>
<TD>



</TABLE>
</body>
</html>

--------------- Added [DATE]1203784756[/DATE] at [TIME]1203784756[/TIME] ---------------

I actually finished this and thank you Hugh for all your help. Can an admin please remove this now. Thank you.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01304 seconds
  • Memory Usage 1,783KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete