ajeet Posted May 15, 2006 Share Posted May 15, 2006 The program below is to calculate simple interest using vbscript-Do we have to use cint also?<html><head><script type="text/vbscript">function check()dim p,r,s,tp=document.form.t1.valuer=document.form.t2.valuet=form.t3.values=p*r*t/100document.write("the simple interest is "&s)if len(form.t1.value)=0 thenmsgbox"invalid entry to box 1"if len(form.t2.value)=0 thenmsgbox"invalid entry to box 2"if len(form.t3.value)=0 thenmsgbox"invalid entry to box 3"end ifend ifend if end function</script></head><body><form name="form"><p>principal amount: <input type="text" name="t1"></p>Rate of Interest: <input type="text" name="t2"><br><p>time: <input type="text" name="t3"><br></p><input type="button" value="click" OnClick=check()></form></body></html> Link to comment Share on other sites More sharing options...
pulpfiction Posted May 15, 2006 Share Posted May 15, 2006 Hi,It is not necessary that you will need CInt function, it will just round off the number. but you will need to make sure that only numbers are given in the textbox or your calculation will throw an error. another thing is that the if statement to check if the textbox is empty must be ahead of the calculation..HTH Link to comment Share on other sites More sharing options...
ajeet Posted May 16, 2006 Author Share Posted May 16, 2006 Thanks for your reply....Can you tell wat is t difference b\w "type="text\vbscript" and language="text\vbscript".many programs are running only using the second format.Too the code below is not doing the addition to calculate the fibonacci series...can you plz help- <html><head><script type="text\vbscript">function fib(n)if (n=0) or (n=1) thendocument.write("zero")exit functionend ifif (n=2) thendocument.write("one")exit functionend ifdim old,current,new,jold=cint(0)current=cint(1)document.write(old & "<br>" & current & "<br>" )for j=3 to n step 1new = old + currentdocument.write(new &"<br>")nextend function</script></head><body><form name="form">Enter the number of terms to calculate:<input type="text" name="t1"><br><input type="button" value="click" OnClick="fib(form.t1.value)"></form></body></html> Link to comment Share on other sites More sharing options...
pulpfiction Posted May 16, 2006 Share Posted May 16, 2006 The answer for your first question..type = content-type [CI] This attribute specifies the scripting language of the element's contents and overrides the default scripting language. The scripting language is specified as a content type (e.g., "text/javascript"). Authors must supply a value for this attribute. There is no default value for this attribute. language = cdata [CI] Deprecated. This attribute specifies the scripting language of the contents of this element. Its value is an identifier for the language, but since these identifiers are not standard, this attribute has been deprecated in favor of type. Link to comment Share on other sites More sharing options...
pulpfiction Posted May 16, 2006 Share Posted May 16, 2006 Try this...<html><head><script type="text\vbscript">function test(n)'dim n'n=4 if (n=0) or (n=1) thendocument.write("zero")exit functionend ifif (n=2) thendocument.write("one")exit functionend ifdim old,current,ne,jold=0current=1document.write(old & "<br>" & current & "<br>" )for j=3 to n step 1ne = old + currentdocument.write(ne &"<br>")old=currentcurrent=nenextend function</script></head><body><form name="form1" onsubmit="test(document.form1.refno.value)"><input type="text" name="refno"><input type=submit value="Submit"></form></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now