turning images on and off
turning images on and off
(OP)
CODE
sub HtmlFilter
{
local($filter) = @_;
#
# The following filters the HTML images
# out, if they are disallowed. The code
# after this, filters out all HTML if it
# is disallowed.
#
if ($no_html_images eq "off")
{
$filter =~ s/<(IMG\s*SRC.*)>/<$1>/ig;
} # End of parsing out no images
if ($no_html eq "on")
{
$filter =~ s/<([^>]+)>/\<$1>/ig;
} # End of No html
$filter;
{
local($filter) = @_;
#
# The following filters the HTML images
# out, if they are disallowed. The code
# after this, filters out all HTML if it
# is disallowed.
#
if ($no_html_images eq "off")
{
$filter =~ s/<(IMG\s*SRC.*)>/<$1>/ig;
} # End of parsing out no images
if ($no_html eq "on")
{
$filter =~ s/<([^>]+)>/\<$1>/ig;
} # End of No html
$filter;
Is there a way to toggle the $no_html_images on and off?
CODE
</TR>
<TR>
<TD ALIGHT=RIGHT>Pic on or off:</TD>
<TD><select size=1 name=no_html_images>
<option selected value=ON>ON</option>
<option value=OFF>OFF</option>
</select></TD>
<TR>
<TD ALIGHT=RIGHT>Pic on or off:</TD>
<TD><select size=1 name=no_html_images>
<option selected value=ON>ON</option>
<option value=OFF>OFF</option>
</select></TD>
I tryed it this way no luck
MA WarGod
I believe if someone can think it, it can be programmed
RE: turning images on and off
<option selected value=ON>ON</option>
but you check for lower-case "on"
if ($no_html eq "on")
change the above line to:
if ($no_html eq 'ON')
- Kevin, perl coder unexceptional!
RE: turning images on and off
and I am still working with the format You gave for begaining.
so thank You again
RE: turning images on and off
CODE
{
local($filter) = @_;
#
# The following filters the HTML images
# out, if they are disallowed. The code
# after this, filters out all HTML if it
# is disallowed.
#
if ($no_html_images eq "off")
{
$filter =~ s/<(IMG\s*SRC.*)>/<$1>/ig;
} # End of parsing out no images
if ($no_html eq "on")
{
$filter =~ s/<([^>]+)>/\<$1>/ig;
} # End of No html
$filter;
} # End of HTML Filter
CODE
<TD><select size=1 name=no_html_images>
<option selected value=on>ON</option>
<option value=off>OFF</option>
</select></TD>
or should I from the sub different
like
if ($no_html_images eq "$_")
{
$filter =~ s/<(IMG\s*SRC.*)>/<$1>/ig;
} # End of parsing out no images
if ($no_html eq "off")
{
$filter =~ s/<([^>]+)>/\<$1>/ig;
} # End of No html
$filter;
????????
RE: turning images on and off
CODE
{
$filter =~ s/<(IMG\s*SRC.*)>/<$1>/ig;
} # End of parsing out no images
if ($no_html eq "on")
or is it supposed to be like that?
- Kevin, perl coder unexceptional!
RE: turning images on and off
Furthermore, testing for "off" and "on" is asking for trouble once you start passing values of "Off", or "ON", or " off", or whatever else. Get used to thinking like a computer and use 1 for yes, 0 for no. Actually, it's quite common in CGI programming to treat any non-zero, non-null value as "yes" and 0 or "" as "no" - so your form could be like this:
CODE
CODE
{
$filter =~ s/<(IMG\s*SRC.*)>/<$1>/ig;
} # End of parsing out no images
-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd