Building and using a field name 
Author Message
 Building and using a field name

I have an onClick event for a checkbox in my ASP page and call my function
like this: onclick="Week(x)"
where x is a number between 1 and 9
I want to do something like this:

function Week()
{  document.frmNew.[FullTime + x].checked=true;

Quote:
}

I know there's a way to do this but can't seem to find it.


Sat, 09 Oct 2004 04:08:50 GMT  
 Building and using a field name
Are you trying to do this on the client side or on the server? You can't
have event handlers in traditional ASP. (I don't know if you can do this
with VBScript because I use 99% JScript in my ASP pages).

Mario Vargas


Quote:
> I have an onClick event for a checkbox in my ASP page and call my function
> like this: onclick="Week(x)"
> where x is a number between 1 and 9
> I want to do something like this:

> function Week()
> {  document.frmNew.[FullTime + x].checked=true;
> }

> I know there's a way to do this but can't seem to find it.



Sat, 09 Oct 2004 04:17:17 GMT  
 Building and using a field name
Sorry, I shouldn't have mentioned ASP.
It has nothing to do with the problem.
This is client side JScript.


Quote:
> Are you trying to do this on the client side or on the server? You can't
> have event handlers in traditional ASP. (I don't know if you can do this
> with VBScript because I use 99% JScript in my ASP pages).

> Mario Vargas



> > I have an onClick event for a checkbox in my ASP page and call my
function
> > like this: onclick="Week(x)"
> > where x is a number between 1 and 9
> > I want to do something like this:

> > function Week()
> > {  document.frmNew.[FullTime + x].checked=true;
> > }

> > I know there's a way to do this but can't seem to find it.



Sat, 09 Oct 2004 04:23:58 GMT  
 Building and using a field name
Gotcha, OK. Yes, you can attach an event handler to a checkbox field in
HTML. And I think you are doing it right, but the code in the Week( x )
function needs to be modified to:

 document.frmNew.elements[ FullTime + x ].checked = true;

What are you trying to display as checked in this code? The checkbox that
the user clicked on?

Also, be aware that when you add new fields to your form in the future, you
might need to rewrite the Week(x) function because the indices in the
elements array will change. One way to get around this is to check the type
property of the field.

Mario Vargas


Quote:
> Sorry, I shouldn't have mentioned ASP.
> It has nothing to do with the problem.
> This is client side JScript.



> > Are you trying to do this on the client side or on the server? You can't
> > have event handlers in traditional ASP. (I don't know if you can do this
> > with VBScript because I use 99% JScript in my ASP pages).

> > Mario Vargas



> > > I have an onClick event for a checkbox in my ASP page and call my
> function
> > > like this: onclick="Week(x)"
> > > where x is a number between 1 and 9
> > > I want to do something like this:

> > > function Week()
> > > {  document.frmNew.[FullTime + x].checked=true;
> > > }

> > > I know there's a way to do this but can't seem to find it.



Sat, 09 Oct 2004 04:42:58 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. A SELECT statement on a name field with an apostrophe in the name

2. building a fiend name

3. How to build an object name?

4. Building Object Names with Strings

5. build dynamic Dim from computer names

6. Class method names same as built-in functions?

7. Class method names same as built-in functions?

8. field names

9. Accessing mulitple text fields with the same name?

10. Illegal characters in form field names...

11. Illegal characters in form field names...

12. How to handle dynamically generated field names

 

 
Powered by phpBB® Forum Software