checking a checkbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Lee

    checking a checkbox

    Hi

    Is it possible to preset the values of form elements with php - so that when
    the client gets the page certain boxes are checked or completed - on the
    fly - based on their HTML id.

    Javascript has a way of doing this - but i need the functionality of PHP
    too - so if i can move the whole thing over to php it owuld be better .

    javascript example -

    document.forms['form1'].elements['radiobuttonno'].checked = true;


    many thanks

    AL



  • Andy Hassall

    #2
    Re: checking a checkbox

    On Sat, 15 May 2004 18:05:30 +0100, "Andy Lee" <no_email@no_em ail.com> wrote:
    [color=blue]
    >Hi
    >
    >Is it possible to preset the values of form elements with php - so that when
    >the client gets the page certain boxes are checked or completed - on the
    >fly - based on their HTML id.
    >
    >Javascript has a way of doing this - but i need the functionality of PHP
    >too - so if i can move the whole thing over to php it owuld be better .
    >
    >javascript example -
    >
    >document.for ms['form1'].elements['radiobuttonno'].checked = true;[/color]

    Add a checked="checke d" attribute when you print out the checkbox.

    <input type="checkbox" name="whatever" value="somethin g" checked="checke d">

    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

    Comment

    • Andy Lee

      #3
      Re: checking a checkbox

      Unfortunately that wont work - as i have to loop through mysql values
      combined with REquested variables in the querystring. I need to set a
      varying number of form elements values on the fly






      "Andy Hassall" <andy@andyh.co. uk> wrote in message
      news:4ojca0lhlm u2947h8ef1d2cts t2v0pue5n@4ax.c om...[color=blue]
      > On Sat, 15 May 2004 18:05:30 +0100, "Andy Lee" <no_email@no_em ail.com>[/color]
      wrote:[color=blue]
      >[color=green]
      > >Hi
      > >
      > >Is it possible to preset the values of form elements with php - so that[/color][/color]
      when[color=blue][color=green]
      > >the client gets the page certain boxes are checked or completed - on the
      > >fly - based on their HTML id.
      > >
      > >Javascript has a way of doing this - but i need the functionality of PHP
      > >too - so if i can move the whole thing over to php it owuld be better .
      > >
      > >javascript example -
      > >
      > >document.for ms['form1'].elements['radiobuttonno'].checked = true;[/color]
      >
      > Add a checked="checke d" attribute when you print out the checkbox.
      >
      > <input type="checkbox" name="whatever" value="somethin g"[/color]
      checked="checke d">[color=blue]
      >
      > --
      > Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
      > http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space[/color]


      Comment

      • Andy Hassall

        #4
        Re: checking a checkbox

        On Sat, 15 May 2004 19:07:41 +0100, "Andy Lee" <no_email@no_em ail.com> wrote:
        [color=blue]
        >"Andy Hassall" <andy@andyh.co. uk> wrote in message
        >news:4ojca0lhl mu2947h8ef1d2ct st2v0pue5n@4ax. com...[color=green]
        >> On Sat, 15 May 2004 18:05:30 +0100, "Andy Lee" <no_email@no_em ail.com>[/color]
        >wrote:[color=green]
        >>[color=darkred]
        >>>Is it possible to preset the values of form elements with php - so that
        >>>when the client gets the page certain boxes are checked or completed - on the
        >>>fly - based on their HTML id.
        >>>
        >>>Javascript has a way of doing this - but i need the functionality of PHP
        >>>too - so if i can move the whole thing over to php it owuld be better .
        >>>
        >>>javascript example -
        >>>
        >>>document.for ms['form1'].elements['radiobuttonno'].checked = true;[/color]
        >>
        >> Add a checked="checke d" attribute when you print out the checkbox.
        >>
        >> <input type="checkbox" name="whatever" value="somethin g"[/color]
        >checked="check ed">
        >
        >Unfortunatel y that wont work - as i have to loop through mysql values
        >combined with REquested variables in the querystring. I need to set a
        >varying number of form elements values on the fly[/color]

        So? If you're not printing out the form elements from PHP, how exactly are
        they getting to the browser? If you're printing them, you can add attributes
        when you print them.

        --
        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
        http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

        Comment

        Working...