Reply
Looping: reading in form values
Old 06-12-2006, 07:19 AM Looping: reading in form values
Skilled Talker

Posts: 95
Hi, I've created my self a problem.

In ASP using VBscript i have one form that displays 5 input boxes per row.
So the page could have 5 boxes on it or it could have 105 or any number divisible by 5

so how do i read in the 5 or what ever textboxes?

i figure i to do it in a loop.

so i have read in my counter this tells me the number of boxes i have to loop through)

so this i what i was thinking

for( i=1;i<=counter;i++)
{
var textbox = Form1.txtbox+i.value
}
this doesnt work. so does any one know of a way to do what i'm after.
thanks

Last edited by higginbt : 06-12-2006 at 07:20 AM.
higginbt is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 06-12-2006, 08:33 AM Re: Looping: reading in form values
chrishirst's Avatar
Super Moderator

Posts: 13,608
Location: Blackpool. UK
from VbScript setting a variable in the javascript code how many boxes there are would be one way

Code:
var box_count = <%=Number_of_boxes%>
other than that seeing some code for the text boxes and a better explanation of what you are trying to do would be helpful
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-12-2006, 09:40 AM Re: Looping: reading in form values
Skilled Talker

Posts: 95
Thanks chrishirist

I think i figured it out using form.elements
this is what i've come up with

function checkform(form,btn)
{
pass = true
for(x=0; x<document.Form1.elements.length; x++)
{
if(document.Form1.elements[x].type == "text")
{

if (!IsNumeric(document.Form1.elements[x].value))
{
NumericErr ="Please enter numeric values only\r"
pass = false
}

//alert(document.Form1.elements[x].name)
//alert(document.Form1.elements[x].value)
}
}

This loops through all form elements be it buttons, or any type of input box.
Ignores any that are not type =text. then checks to see if the value for that box is numeric if it is then, at the end it will display a message and stop the the form beging submitted

Again, im not sure if this is the best method cause i'm basically learning javascript as i go. i.e figure out waht i need to do, then figure out how to do it.
higginbt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Looping: reading in form values
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13360 seconds with 12 queries