I have this html / javascript : -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
var c;
function a_int_b(form){
c=0;
a=eval(form.a.value);
b=eval(form.b.value);
c=a;
for(var i = 0;i<b;i++){
c =c*1.00482;
}
form.ans.value = c.toFixed(2);
}
//-->
</script>
</head>
<body>
<form>
amount<input type ="text" name="a" size="20"><br>
months<input type ="text" name="b" size="20"><br>
amount with interests<input type ="text" name="ans" size="20"><br>
<input type ="button" onClick="a_int_b(this.form)">
</form>
</body>
</html>
But I want the 1.00482 to be saved in an external file, eg txt or xls. So it can be changed easily.
I've heard theat this cant be done in java and would want to know if it can be done in php?
External Variables?
Moderator: General Moderators
-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
- Pointybeard
- Forum Commoner
- Posts: 71
- Joined: Wed Sep 03, 2003 7:23 pm
- Location: Brisbane, AUS
- Contact:
This what you mean?
Hope thats right. Just chuck yer value into 'value.txt' and have it in the same dir as the script
-PB
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
var c;
function a_int_b(form){
c=0;
a=eval(form.a.value);
b=eval(form.b.value);
c=a;
for(var i = 0;i<b;i++){
c =c*form.a_constant.value;
}
form.ans.value = c.toFixed(2);
}
//-->
</script>
</head>
<body>
<?php
$handle = fopen("value.txt", "r");
$buffer = fgets($handle, 4096);
define(CONST_VALUE, trim($buffer));
?>
<form>
<input type=hidden name="a_constant" value="<?= CONST_VALUE ?>" />
amount<input type ="text" name="a" size="20"><br>
months<input type ="text" name="b" size="20"><br>
amount with interests<input type ="text" name="ans" size="20"><br>
<input type ="button" onClick="a_int_b(this.form)">
</form>
</body>
</html>-PB
-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
- Pointybeard
- Forum Commoner
- Posts: 71
- Joined: Wed Sep 03, 2003 7:23 pm
- Location: Brisbane, AUS
- Contact: