Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 95
Trades: 0
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 08:20 AM..
higginbt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-12-2006, 09:33 AM Re: Looping: reading in form values
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-12-2006, 10:40 AM Re: Looping: reading in form values
Skilled Talker

Posts: 95
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.12034 seconds with 12 queries