popup_menu defaults

[b][red]This message was edited by Supergibbs at 2004-9-22 12:49:38[/red][/b][hr]
I have a PERL script with a bunch of checkboxes and popup_menus to set permissions for a bunch of users. The script mostly works fine. When the page loads the current permissions are shown, when I update them and submit, they are correctly updated in the MySQL DB. Only wierdness is that after an update, many of the popup_menus show the wrong value. The check boxes are correct though and if I refresh the page they are all correct again. The script POSTs back to itself, is that bad style? It seems to work ok on other scripts. Anyone heard of somthing similar?

Also I am using the CGI module, not doing it by hand.

-Supergibbs


Comments

  • : [b][red]This message was edited by Supergibbs at 2004-9-22 12:49:38[/red][/b][hr]
    : I have a PERL script with a bunch of checkboxes and popup_menus to set permissions for a bunch of users. The script mostly works fine. When the page loads the current permissions are shown, when I update them and submit, they are correctly updated in the MySQL DB. Only wierdness is that after an update, many of the popup_menus show the wrong value. The check boxes are correct though and if I refresh the page they are all correct again. The script POSTs back to itself, is that bad style? It seems to work ok on other scripts. Anyone heard of somthing similar?
    :
    : Also I am using the CGI module, not doing it by hand.
    :
    I don't think it's bad style at all - I certainly do things like this all of the time. IMHO, you should always use one of the following two schemes:-

    1) Always pull any data from the database that you are going to display AFTER all updates/inserts/deletes have taken place. If you grab some of it beforehand, you'll have old values.
    2) Always use the submitted formdata and display that. I don't use the CGI module, but under the system I use I can populate the form data hash (just the way what I use works) with data from the database if we are not responding to an existing POST. It tends to work quite nicely.

    If you mix and match 1 and 2, things can get confusing.

    Not sure how helpful this will be, but from what you describe it sounds like you are doing (1), but fetching data from the database too early.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • [b][red]This message was edited by Supergibbs at 2004-9-22 16:40:51[/red][/b][hr]
    UPDATE: I printed out the values and they are correct. It is is just the popup_menu that isn't using them. Bug in CGI?

    Thanks but that isn't it. I checked that I hit the DB before the forms. One possibility is that I use a 2D Hash and may be doing that wrong, though it works on a fresh load.... here is my syntax

    [code]
    while (my $ref = $sth->fetchrow_hashref())
    {
    push @users, $ref->{'email'};
    $names{$ref->{'email'}} = "$ref->{'first'} $ref->{'last'}";
    foreach $curr (@fields)
    {
    $perms->{"$ref->{'email'}"}->{"$curr"} = $ref->{"$curr"}; #HERE!!
    }
    }
    [/code]


    basically it loads the permission (a number) for each item (#HERE!!) Does that look right?

    And to retrieve the value I use:

    [code]
    $perms->{$user}->{$curr}
    [/code]

    Thanks,
    Supergibbs


    : : [b][red]This message was edited by Supergibbs at 2004-9-22 12:49:38[/red][/b][hr]
    : : I have a PERL script with a bunch of checkboxes and popup_menus to set permissions for a bunch of users. The script mostly works fine. When the page loads the current permissions are shown, when I update them and submit, they are correctly updated in the MySQL DB. Only wierdness is that after an update, many of the popup_menus show the wrong value. The check boxes are correct though and if I refresh the page they are all correct again. The script POSTs back to itself, is that bad style? It seems to work ok on other scripts. Anyone heard of somthing similar?
    : :
    : : Also I am using the CGI module, not doing it by hand.
    : :
    : I don't think it's bad style at all - I certainly do things like this all of the time. IMHO, you should always use one of the following two schemes:-
    :
    : 1) Always pull any data from the database that you are going to display AFTER all updates/inserts/deletes have taken place. If you grab some of it beforehand, you'll have old values.
    : 2) Always use the submitted formdata and display that. I don't use the CGI module, but under the system I use I can populate the form data hash (just the way what I use works) with data from the database if we are not responding to an existing POST. It tends to work quite nicely.
    :
    : If you mix and match 1 and 2, things can get confusing.
    :
    : Not sure how helpful this will be, but from what you describe it sounds like you are doing (1), but fetching data from the database too early.
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :



  • This thread is kinda old - did you solve it or do you still need help?

    Sorry it's taken me so long to get back to you,

    Jonathan

    : [b][red]This message was edited by Supergibbs at 2004-9-22 16:40:51[/red][/b][hr]
    : UPDATE: I printed out the values and they are correct. It is is just the popup_menu that isn't using them. Bug in CGI?
    :
    : Thanks but that isn't it. I checked that I hit the DB before the forms. One possibility is that I use a 2D Hash and may be doing that wrong, though it works on a fresh load.... here is my syntax
    :
    : [code]
    : while (my $ref = $sth->fetchrow_hashref())
    : {
    : push @users, $ref->{'email'};
    : $names{$ref->{'email'}} = "$ref->{'first'} $ref->{'last'}";
    : foreach $curr (@fields)
    : {
    : $perms->{"$ref->{'email'}"}->{"$curr"} = $ref->{"$curr"}; #HERE!!
    : }
    : }
    : [/code]
    :
    :
    : basically it loads the permission (a number) for each item (#HERE!!) Does that look right?
    :
    : And to retrieve the value I use:
    :
    : [code]
    : $perms->{$user}->{$curr}
    : [/code]
    :
    : Thanks,
    : Supergibbs
    :
    :
    : : : [b][red]This message was edited by Supergibbs at 2004-9-22 12:49:38[/red][/b][hr]
    : : : I have a PERL script with a bunch of checkboxes and popup_menus to set permissions for a bunch of users. The script mostly works fine. When the page loads the current permissions are shown, when I update them and submit, they are correctly updated in the MySQL DB. Only wierdness is that after an update, many of the popup_menus show the wrong value. The check boxes are correct though and if I refresh the page they are all correct again. The script POSTs back to itself, is that bad style? It seems to work ok on other scripts. Anyone heard of somthing similar?
    : : :
    : : : Also I am using the CGI module, not doing it by hand.
    : : :
    : : I don't think it's bad style at all - I certainly do things like this all of the time. IMHO, you should always use one of the following two schemes:-
    : :
    : : 1) Always pull any data from the database that you are going to display AFTER all updates/inserts/deletes have taken place. If you grab some of it beforehand, you'll have old values.
    : : 2) Always use the submitted formdata and display that. I don't use the CGI module, but under the system I use I can populate the form data hash (just the way what I use works) with data from the database if we are not responding to an existing POST. It tends to work quite nicely.
    : :
    : : If you mix and match 1 and 2, things can get confusing.
    : :
    : : Not sure how helpful this will be, but from what you describe it sounds like you are doing (1), but fetching data from the database too early.
    : :
    : : Jonathan
    : :
    : : ###
    : : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    : :
    : :
    :
    :
    :
    :


    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • Yea, thanks for checking up on it though. CGI does wierd stuff sometimes. I had a space in the name of the popup_menus for delimiting and that cause this error. Replacing it with a character fixed it.

    -Jesse

    : This thread is kinda old - did you solve it or do you still need help?
    :
    : Sorry it's taken me so long to get back to you,
    :
    : Jonathan
    :
    : : [b][red]This message was edited by Supergibbs at 2004-9-22 16:40:51[/red][/b][hr]
    : : UPDATE: I printed out the values and they are correct. It is is just the popup_menu that isn't using them. Bug in CGI?
    : :
    : : Thanks but that isn't it. I checked that I hit the DB before the forms. One possibility is that I use a 2D Hash and may be doing that wrong, though it works on a fresh load.... here is my syntax
    : :
    : : [code]
    : : while (my $ref = $sth->fetchrow_hashref())
    : : {
    : : push @users, $ref->{'email'};
    : : $names{$ref->{'email'}} = "$ref->{'first'} $ref->{'last'}";
    : : foreach $curr (@fields)
    : : {
    : : $perms->{"$ref->{'email'}"}->{"$curr"} = $ref->{"$curr"}; #HERE!!
    : : }
    : : }
    : : [/code]
    : :
    : :
    : : basically it loads the permission (a number) for each item (#HERE!!) Does that look right?
    : :
    : : And to retrieve the value I use:
    : :
    : : [code]
    : : $perms->{$user}->{$curr}
    : : [/code]
    : :
    : : Thanks,
    : : Supergibbs
    : :
    : :
    : : : : [b][red]This message was edited by Supergibbs at 2004-9-22 12:49:38[/red][/b][hr]
    : : : : I have a PERL script with a bunch of checkboxes and popup_menus to set permissions for a bunch of users. The script mostly works fine. When the page loads the current permissions are shown, when I update them and submit, they are correctly updated in the MySQL DB. Only wierdness is that after an update, many of the popup_menus show the wrong value. The check boxes are correct though and if I refresh the page they are all correct again. The script POSTs back to itself, is that bad style? It seems to work ok on other scripts. Anyone heard of somthing similar?
    : : : :
    : : : : Also I am using the CGI module, not doing it by hand.
    : : : :
    : : : I don't think it's bad style at all - I certainly do things like this all of the time. IMHO, you should always use one of the following two schemes:-
    : : :
    : : : 1) Always pull any data from the database that you are going to display AFTER all updates/inserts/deletes have taken place. If you grab some of it beforehand, you'll have old values.
    : : : 2) Always use the submitted formdata and display that. I don't use the CGI module, but under the system I use I can populate the form data hash (just the way what I use works) with data from the database if we are not responding to an existing POST. It tends to work quite nicely.
    : : :
    : : : If you mix and match 1 and 2, things can get confusing.
    : : :
    : : : Not sure how helpful this will be, but from what you describe it sounds like you are doing (1), but fetching data from the database too early.
    : : :
    : : : Jonathan
    : : :
    : : : ###
    : : : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : : : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : : : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    : : :
    : : :
    : :
    : :
    : :
    : :
    :
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories