#1
  1. webber
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2000
    Location
    San Juan - Argentina
    Posts
    594
    Rep Power
    15

    Talking Mixture of JavaScript & PHP


    Hi.
    I've a database. When user logs, see a form he must submit so the search in database begins...
    Each result is a page (with next/prev btns) with a table...
    All works fine, but i was told to add at the end of the table a little
    CHECKBOX (unchecked).
    So, i need to do this...
    When user checkes the checkbox, a form must be submitted instantly, so the check user has made is updated in database...
    After that, when user logins another day, i should check the state of a BOOL field in that db, so i display the checkbox CHECKED or UNCHECKED (representing 1 if checked or 0 if not...)

    The main problem i have is to submit the form when user checks, unchecks the checkbox... besides that... all is fine...

    I think it maybe a behavior or anything like that...
    am i right?

    Thanks 4 reading!
    Thanks in advance. C ya!
    Enrique Becerra
    CodeIgniter, Joomla & Java Development
    www.itexa.com.ar
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    It would have to be javascript. Not sure of the behavior or event, though...maybe onchange, or onclick?

    If it's something like that, you can use this:

    <input type=checkbox name=check value='1' onclick="submit();">

    ---John Holmes...
    -- Cigars, whiskey and wild, wild women. --
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Location
    Boston
    Posts
    261
    Rep Power
    14
    I use this script:

    <script langauge="javascript">
    function submitForm(FormName){
    eval('document.' + FormName + '.submit()');
    }
    </script>


    and in my input tag have "onchange='submitForm(formName)'"

    so for you it would be:
    <input type=checkbox name=whatever value=something onchange=submitform(formName)>

    hope this helps
  6. #4
  7. webber
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2000
    Location
    San Juan - Argentina
    Posts
    594
    Rep Power
    15

    Talking All worked... but


    When i click the checkbox the form submits fine... but i can check the $var only when checkbox is checked...
    I mean:
    If checkbox is checked and i uncheck it, the form submits but the $var_checkbox is empty or null...
    But when the checkbox is unchecked and i check it, the form submits and the $var_checkbox is with its value...
    Is any way to "fix this"?

    Thanks in advance.

    Hope you've understood me...
    Enrique Becerra
    CodeIgniter, Joomla & Java Development
    www.itexa.com.ar
  8. #5
  9. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    No...that's the way it works. If it's not checked, the variable is null.

    ---John Holmes...

IMN logo majestic logo threadwatch logo seochat tools logo