Results 1 to 3 of 3
  1. #1

    Accessing a control in a form

    One way to do it is of course

    formname.controlname

    However, can we access it differently?

    What about formname.item("controlname")?

    It doesn't work though.

    I've tried in

    http://seminarindonesia.com/index2.htm

    Here,

    if(IsEmpty(frm1.FirstName)) would work fine

    but

    //if(IsEmpty(frm1.item("FirstName")) doesn't work

    Why?

    The problem with frm1.FirstName is that the control name cannot contain space. I want a control name that contains space like First Name instead of First Name.

  2. #2
    Join Date
    Feb 2005
    Posts
    105
    I'm not sure what programming language you are using but the reason why variables contain no spaces is because it is harder to distinguish between one variable or two if spaces are allowed.

    Say you have 3 variables:
    First
    Name
    First Name

    and you want to print First Name. Well printing First Name might print First and Name, but not variable First Name. Was that confusing? Exactly why we don't want spaces in variables... or controls.

  3. #3
    I use document.getElementById() for everything. I would also discourage you from using whitespace in variables. I mean what if you want to write your back end in this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •