#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    1
    Rep Power
    0

    Question VBscript Prime #'s in textbox?


    Hi i'm writing a VBscript that should output all of Prime numbers inside a textbox.. so far i've been able to create a code that prints all of the prime number below 100 but im having a problem putting them inside the textbox... i dont have any idea on how to loop a texbox with different value..

    heres my code:
    Code:
    <html> 
    <body> 
    <script type="text/vbscript">
    For num = 3 To 100 Step 2 
       bIsPrime = True
       For i = 2 To num\2 
          bIsPrime = num Mod i > 0 
          If Not bIsPrime then exit for 
       Next
       If bIsPrime Then 
          document.write(num & "<input type='text' size=10><br/>")
       end if
    Next 
    </script> 
    </body> 
    </html>
    sorry but i'm just a newbie on scripting...
    i need help on how to put the value i looped inside the textbox..

    thanks for reading..
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,424
    Rep Power
    4539
    I suspect you'll need to find the answer in a html/DOM oriented forum, structurally your vbscript appears correct.

    I'd recommend not using vbscript for browser code anyway, javascript is better for browser-side code.
    ======
    Doug G
    ======
    The man who doesn't read good books has no advantage over the man who can't read them.
    --Mark Twain
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    15
    Rep Power
    0
    Originally Posted by Vipe
    Hi i'm writing a VBscript that should output all of Prime numbers inside a textbox.. so far i've been able to create a code that prints all of the prime number below 100 but im having a problem putting them inside the textbox... i dont have any idea on how to loop a texbox with different value..

    heres my code:
    Code:
    <html> 
    <body> 
    <script type="text/vbscript">
    For num = 3 To 100 Step 2 
       bIsPrime = True
       For i = 2 To num\2 
          bIsPrime = num Mod i > 0 
          If Not bIsPrime then exit for 
       Next
       If bIsPrime Then 
          document.write(num & "<input type='text' size=10><br/>")
       end if
    Next 
    </script> 
    </body> 
    </html>
    sorry but i'm just a newbie on scripting...
    i need help on how to put the value i looped inside the textbox..

    thanks for reading..

    if your function is working...
    then the output can be added like this:

    document.write( "<input type='text' size='10' value=''' & num & "'><br/>")

IMN logo majestic logo threadwatch logo seochat tools logo