Click to See Complete Forum and Search --> : Client-side Javascript - how can I find all form fields?


PaulS
04-03-2003, 05:09 AM
Hi,

I'm doing some ASP with client-side JavaScript instead of VBScript.

Everything's going OK apart from one set of pages where I need to be able to get at form field names and the stuff in form fields. The form is created by the user, with various fields being added when they want them (e.g. more textarea input boxes.) So I don't know what all of the fields are going to be called when they come through.

So I could receive these fields, e.g.:

text_1
text_2
image_1
text_3
image_2

I don't know how many 'image_' or 'text_' will be coming through until the form is submitted.

Is there some way I can use a loop to go through the field names that have been submitted so I can find out what's come through and can process it? I've done this in ColdFusion, but can't find out how in server-side Javascript, all the examples I've seen are for client-side stuff.

Thanks

Paul.

PaulS
04-03-2003, 08:08 AM
Yup, thanks Dave. I've been able to find examples of doing it in more standard ASP, unfortunately the rest of the site is in server-side Javascript so I'm trying to find a way of doing it in that.

As much as anything else, I just need the bit that lets it reference all form fields, i.e. a replacement for the

For Each fld in Request.Form

line.

I've managed to find client-side examples, just nothing from the server-side, erm... side.

Cheers

Paul.

PaulS
04-04-2003, 03:00 AM
Thanks Dave, you're a star, that should get me working on the final bit of the project.

I just realised I have put 'client-side' as the thread topic when I meant 'server-side', it's been a long week but God, I feel stupid! Thanks for answering my question with what I was after rather than what I was posting about.

Cheers

Paul.

PaulS
04-04-2003, 05:44 AM
Just another solution a friend sent me, for anyone else trying to do something similar:


<%@ Language = Javascript %>
<%
items = new Enumerator(Request.Form) ;
while (!items.atEnd()) {
i=items.item() ;
Response.write(i+" = "+Request.Form(i)+"<br/>") ;
items.moveNext() ;
}
%>


Regards

Paul.