#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    2

    Chek radio button based in database


    Hello i am trying to edit data that i get from database, and change them. But the problem is with radio button i dont know hoe to check the radio button based in data that i get from database. For example if i get 'female' it should be checked radio button that represent 'F'.

    Code:
     while (my @data = $sqlQuery->fetchrow_array()) {
            $cGender  = $data[3];            	       
        }
        my $cInput_form = '';
        $cInput_form .= $q->start_form (-method => 'post', -action => "" );
        $cInput_form .= $q->legend ({-class => "ui-widget-header ui-corner-all"},"Modify");
        
        $cInput_form .= $q->div({-class => 'control-group'});
        $cInput_form .= $q->label({-class =>'control-label',-for => 'gender'}, "Gender:");
        $cInput_form .= $q->div({-class => 'controls'});
        $cInput_form .= $q->input ({-id => 'gender', -name => 'gender' ,-type => 'radio', value => 'male',},"M");
        $cInput_form .= $q->input ({-id => 'gender', -name => 'gender' ,-type => 'radio', value => 'female'},"F","<br>");
    i really need some help! Thank you!
  2. #2
  3. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,259
    Rep Power
    1810
    A radio_group would probably work well:

    Code:
    my %genders = (M => 'Male', F => 'Female');
    
    print header, start_html('test');
    
    my $cInput_form = $q->start_form (-method => 'post', -action => "" );
    $cInput_form .= $q->legend ({-class => "ui-widget-header ui-corner-all"},"Modify");
    $cInput_form .= $q->label({-class =>'control-label',-for => 'gender'}, "Gender:");
    $cInput_form .= $q->radio_group('gender',['M','F'], $cGender,'true',\%genders);
    
    print $cInput_form, end_html;
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    2
    Thank you it works i want something else. At the moment i click 'Update' button to show me an alert "it's updating " for 5 sec, after that to disappear and perform the update action. I have searched in google but there seems not to be possible to do this with alert
  6. #4
  7. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,259
    Rep Power
    1810
    If you want an alert to display on the client side, the usual way would be in javascript. There are javascript libraries such as jQuery which make it easy to do, and there are probably already some add-on alert window modules which would do the job pretty easily.

    I wouldn't advise it in this case. You may have good reason, but in most applications a user is going to be much more impressed by speed and ease of use. If you quickly do what they say, or accomplish a task with the fewest possible mouse clicks, they will notice and appreciate that.

    Making a user wait five seconds before you do the thing they asked will annoy them.

    Edit: when performing a dangerous action, such as a delete, it is perfectly acceptable to prompt for confirmation. jQuery has some good modules for that.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    2
    ok thank you

IMN logo majestic logo threadwatch logo seochat tools logo