Jump to content

plz check the code


Recommended Posts

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...