Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    check boxes and URL rewriting

    Hi Guys, Hope someone can help me with my code. i am using rewritten URL's and have this piece of code on a form. When the page first loads mypage.htm, the type_24 checkbox get's checked by default. If they check the type_12 box, i want the type_24 box to uncheck.

    My problem is, if i check the type_12 box, the page refreshes and both the type_12 and type_24 boxes are checked.. which is not what i want. I think it's because i'm reloading my rewritten URL in my action because it works fine if i just have php file as the action.

    Any ideas how i can fix my code so that it only has the type_12 checked when i check the type_24 box?

    <form name="frmrefresh" id="frmrefresh" method="post" action="mypage.htm">

    <input type="checkbox" name="type_12" id="type_12" <?php if(isset($_POST['type_12']) && $_POST['type_12']=="12"){?> checked="checked"<?php }?> value="12" onClick="uncheck24(this);" /> <label>12</label>

    <input type="checkbox" name="type_24" id="type_24" <?php if(isset($_GET['id']) && $_GET['id']!=''){?>checked="checked"<?php }?><?php if(isset($_POST['month_24']) && $_POST['type_24']=="24"){?> checked="checked"<?php }?> value="24" onClick="uncheck12(this);"/> <label>24 Months</label>

    <input type="hidden" name="id" value="<?php echo $_REQUEST['id'];?>" />
    </form>

    In the header i have the functions:

    function uncheck12(obj)
    {
    if (obj.checked == true)
    {
    document.getElementById("type_12").checked = false;
    document.frmrefresh.submit();
    }
    }

    function uncheck24(obj)
    {
    if (obj.checked == true)
    {
    document.getElementById("type_24").checked = false;
    document.frmrefresh.submit();
    }
    }

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,092
    Thanks
    23
    Thanked 594 Times in 593 Posts
    Lots of code to do what RADIO buttons do. Just have mypage.htm check their status and refresh the page with the correct one set.http://www.echoecho.com/htmlforms10.htm


  •  

    Posting Permissions

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