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

    Question conflict post help

    I have a registration form, wherein, it has a dropdown menu of pre-made questions to serve as secret questions. then I added a "write my own secret question" link wherein, if I click this link, it'll hide the dropdown menu and then show a textbox instead.

    here's my jquery script

    			$ ('#ownSecret').hide();
    here's the php code snippet

    PHP Code:
    <div id="dropSecret" class="row">
        <?php echo CHtml::activeLabelEx($form,'WSMembershipSecretQuestion'); ?>
        <?php echo CHtml::activeDropDownList($form,'WSMembershipSecretQuestion',$form->getSecretQuestions()); ?>

    <?php echo CHtml::link('write my own secret question','#',array('id'=>'ownSecret')); ?>

    <div id="textSecret" class = "row">
        <?php echo CHtml::activeLabelEx($form,'WSMembershipSecretQuestion'); ?>
        <?php echo CHtml::activeTextArea($form,'WSMembershipSecretQuestion', array('rows' => 2,'cols' =>15)); ?>

    <div class = "row"> 
        <?php echo CHtml::activeLabelEx($form,'WSMembershipSecretAnswer'); ?>
        <?php echo CHtml::activeTextField($form,'WSMembershipSecretAnswer'); ?>
    now the problem is, this

    the dropdown menu questionaire doesn't seem to get recognized when I submit the form..it only knows the text box version for writing own question when they both have the same attribute name

    what should I do ?
    Last edited by capt_nemo777; 12-01-2010 at 09:38 AM.

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Some say it's everything.
    Thanked 397 Times in 390 Posts
    Rather than hiding the unused dropdown you could remove it (or still hide it, but also move it outside of the form so that it isn't included in the form validation).

    Or you could dynamically create an option in the dropdown that is "throwaway" and set your PHP up to ignore the variable if the result is that throwaway value. You would still have a conflict if the name matches your new text box though.

    Really, you have a number of possible solutions, but two form elements should not have the same name unless it is a radio switch.
    Last edited by Rowsdower!; 12-01-2010 at 02:53 PM.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting


    Posting Permissions

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