Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Perl CGI -disabled

by misterperl (Pilgrim)
on Sep 22, 2014 at 14:31 UTC ( [id://1101533]=perlquestion: print w/replies, xml ) Need Help??

misterperl has asked for the wisdom of the Perl Monks concerning the following question:

I guess this is more of an HTML question than Perl, but I've read the detailed desctiption of the cgi.pm -disabled switch (used on an input text box) and all it says is it prevents the user from clicking into the box. Which is exactly what I need.

But IN ADDITION, the param seems to vanish from the cgi returned from the page? That seems particularly undesirable, since now I'm having to push it in with a cgi->hidden to get the dataset proper again.

Is the disappearing param an actual built-in functionality of disabled, or is something else going on?

-disabled is also one of those oddball switches where it's specification is undefined. Some pages suggest you use -disabled => 1,
others -disabled => 'on',
and others say -disabled,
is sufficient. Aggregated docs are unclear.
TY and happy Monday.

Replies are listed 'Best First'.
Re: Perl CGI -disabled
by McA (Priest) on Sep 22, 2014 at 15:07 UTC

    Hi,

    I couldn't find a hint on that -disabled in the perldoc of CGI concerning an input field. But anyways: When you have a chance to create your HTML tags by hand you could use the HTML attribute readonly for input fields (http://www.w3schools.com/tags/att_input_readonly.asp). When I'm not totally wrong the value of that input field should be transmitted back to the server.

    Regards
    McA

      The quality of W3Schools you linked to has been disputed, but they explain -disabled together with its behaviour when submitted: http://www.w3schools.com/tags/att_input_disabled.asp
      Tip: Disabled <input> elements in a form will not be submitted.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        OT: I think W3Schools gets an unfair shake. As you note, they had the right answer in this case. I reported a documentation/interpretation bug to the webmaster back in 2002 or something and got an immediate response and fix.

        (update, s/a/an/; DERP.)

        Thanks for the valueable annotation. I haven't found that. By the way: I never ever used CGI.pm to produce HTML. It felt always clumsy to me.

        I have to admit: W3Schools was the first result at Google. :-)

        McA

Re: Perl CGI -disabled
by ikegami (Patriarch) on Sep 22, 2014 at 15:38 UTC
    You want to set the readonly attribute, not the disabled one. (Bonus: Browsers tend to allow copying of text in readonly controls, but not disabled ones.)

    Is the disappearing param an actual built-in functionality of disabled, or is something else going on?

    It's required by the HTML spec. (Only successful controls are submitted, and "Controls that are disabled cannot be successful.")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1101533]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-25 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found