SharePoint 2007 Calculator
Does anyone know how to create a simple calculator using CEWPs or Form Web Parts on SharePoint 2007? Basically all I need is two fields for input and a submit button which uses the 2 input fields in a function and then gives the answer.
Sounds simple but everything I've tried (using html and javascript) produces an error in SharePoint, even if it works in a normal html page!!
Thanks in advance, Karl
<HTML>
<HEAD>
<TITLE>Saves Calculator</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function CalculateSaves(Atext, Btext, form)
{
var A = parseFloat(Atext);
var B = parseFloat(Btext);
form.Answer.value = ((((A * B)/60)/60)/7.33)/19;
}
function ClearForm(form)
{
form.input_A.value = "";
form.input_B.value = "";
form.Answer.value = "";
}
</SCRIPT>
</HEAD>
<BO开发者_C百科DY>
<P><FONT SIZE="+2">Saves Calculator</FONT></P>
<FORM NAME="Calculator" METHOD="post">
<P>Time in Seconds: <INPUT TYPE=TEXT VALUE="30" NAME="input_A" SIZE=10> Activities: <INPUT TYPE=TEXT NAME="input_B" SIZE=10></P>
<P><INPUT TYPE="button" VALUE="Calculate Saves" name="AddButton" onClick="CalculateSaves(this.form.input_A.value, this.form.input_B.value, this.form)"> <INPUT TYPE="button" VALUE="Reset" name="ClearButton" onClick="ClearForm(this.form)"></P>
<P>Saves = <INPUT TYPE=TEXT NAME="Answer" SIZE=12></P>
</FORM>
</BODY>
</HTML>
I had the same problem.
- Move the html and javascript to a notepad file, save as .html
- Upload to document library
- Add a Page Viewer webpart to your page, and link it to the html file saved within the library
This should now work.
精彩评论