tel2
asked on
Disabled controls don't pass CGI values?
Hi Experts,
I've been working on some perl & HTML code, and it's been working fine, passing a value from its field, back into itself after submission. However, if the field ever gets disabled during the run, the value of the field seems to not get passed back as a parameter. Here's a simplified version of the code to demonstrate the problem:
1. Why does the value not get passed when the field is disabled? (I don't get this problem if I use "readonly" for example, but I'm not keen on using readonly, for other reasons.)
2. How can I get around this (i.e. make it so the value is still passed when the control is disabled)?
3. By the way, when should I use 'disabled="disabled"' and when should I use just 'disabled'?
Thanks.
Tel2
I've been working on some perl & HTML code, and it's been working fine, passing a value from its field, back into itself after submission. However, if the field ever gets disabled during the run, the value of the field seems to not get passed back as a parameter. Here's a simplified version of the code to demonstrate the problem:
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
my $cgi = CGI->new;
my $test1 = $cgi->param('test1');
$test1 *= 2 if $test1;
$disabled = "disabled" if ...some condition...;
print <<EOF;
Content-Type: text/html; charset=utf-8\n
<html>
<body>
<form method="post" name="main">
<input name="test1" value="$test1" $disabled>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
EOF
Questions:1. Why does the value not get passed when the field is disabled? (I don't get this problem if I use "readonly" for example, but I'm not keen on using readonly, for other reasons.)
2. How can I get around this (i.e. make it so the value is still passed when the control is disabled)?
3. By the way, when should I use 'disabled="disabled"' and when should I use just 'disabled'?
Thanks.
Tel2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all that, mwochnick.
Good to have you on the EE team.
Good to have you on the EE team.
ASKER
Thanks for your response.
Yes, I had started trying using a hidden field (having guessed that might be the work around) before posting this, but was hoping there was a more elegant option. Maybe there isn't.
Are you able to answer question 3? Is the longer form to do with XHTML compatibility, as a website I saw seemed to indicate?
Thanks.