Mailing List Archive

Preventing selected being added to option tags
Hi,

Can someone please clarify how I prevent 'selected' being
automatically added to selects? Here's my embperl file:

[-
$optDisableSelectScan=1;
$optDisableInputScan=1;
-]

<form>
<select name="test">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<input type="submit">
</form>


What happens is that once you submit the form, 'selected' gets
automatically added to the relevant option tag.

How can I prevent this, and set it (or not set it) myself instead??

Many thanks

Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Preventing selected being added to option tags [ In reply to ]
Hi Michael,

> Can someone please clarify how I prevent 'selected' being
> automatically added to selects? Here's my embperl file:

> What happens is that once you submit the form, 'selected' gets
> automatically added to the relevant option tag.
>
> How can I prevent this, and set it (or not set it) myself instead??

What I usually do is structure my simple input processing in a number of
stages. Things are different in places of course but I find this is a
common pattern:

1. if we are not here as a result of a form submission (check a submit
value or something) then seed %fdat with any initial values you want in
your form. ie get from database or set to defaults from the user profile
or whatever.

2. if we *are* here as a result of a form submit then process the form
submit as normal. Here, override values in %fdat if you need to as part
of your processing (eg deleting or explicitly setting
$fdat{select_field} to the value you want preselected.

(1 and 2 can be reversed depending on the type of processing you're
doing)

3. Now go on with the rest of the page and let Embperl do its thing.

This way, there is rarely any code in the body of the page that isn't
just conditional output processing. All the code is readable near the
top and coherently grouped. I just trust Embperl to do the right thing
with escaping values and processing %fdat.

I find it an extremely rare thing that I need to set form values in the
HTML explicitly with this simple approach.

Cheers,

Andrew


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Preventing selected being added to option tags [ In reply to ]
Hi Andrew

Thanks for the response.

I ended up (at least for the time being) doing an
undef($fdat{select_field}) which worked but it seems a bit messy. I
was hoping there was some way to disable this processing with
optDisableSomething.

Anyway, I achieved what I needed to. Many thanks

Michael

On Jan 21, 2008 3:32 PM, Andrew O'Brien <andrewo@oriel.com.au> wrote:
>
> Hi Michael,
>
> > Can someone please clarify how I prevent 'selected' being
> > automatically added to selects? Here's my embperl file:
>
> > What happens is that once you submit the form, 'selected' gets
> > automatically added to the relevant option tag.
> >
> > How can I prevent this, and set it (or not set it) myself instead??
>
> What I usually do is structure my simple input processing in a number of
> stages. Things are different in places of course but I find this is a
> common pattern:
>
> 1. if we are not here as a result of a form submission (check a submit
> value or something) then seed %fdat with any initial values you want in
> your form. ie get from database or set to defaults from the user profile
> or whatever.
>
> 2. if we *are* here as a result of a form submit then process the form
> submit as normal. Here, override values in %fdat if you need to as part
> of your processing (eg deleting or explicitly setting
> $fdat{select_field} to the value you want preselected.
>
> (1 and 2 can be reversed depending on the type of processing you're
> doing)
>
> 3. Now go on with the rest of the page and let Embperl do its thing.
>
> This way, there is rarely any code in the body of the page that isn't
> just conditional output processing. All the code is readable near the
> top and coherently grouped. I just trust Embperl to do the right thing
> with escaping values and processing %fdat.
>
> I find it an extremely rare thing that I need to set form values in the
> HTML explicitly with this simple approach.
>
> Cheers,
>
> Andrew
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Preventing selected being added to option tags [ In reply to ]
Michael Smith schrieb:
> Hi Andrew
>
> Thanks for the response.
>
> I ended up (at least for the time being) doing an
> undef($fdat{select_field}) which worked but it seems a bit messy. I
> was hoping there was some way to disable this processing with
> optDisableSomething.
>
>
set Embperl_Syntax to "EmbperlBlocks" to prevent Embperl from
processing HTML-Tags
http://www.ecos.de/embperl/pod/doc/Config.-page-2-.htm#sect_62



--
mit freundlichem Gruß,

Frank Wesemann
Fotofinder GmbH USt-IdNr. DE812854514
Software Entwicklung Web: http://www.fotofinder.net/
Potsdamer Str. 96 Tel: +49 30 25 79 28 90
10785 Berlin Fax: +49 30 25 79 28 999

Sitz: Berlin
Amtsgericht Berlin Charlottenburg (HRB 73099)
Geschäftsführer: Ali Paczensky




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Preventing selected being added to option tags [ In reply to ]
Hi Frank,

> set Embperl_Syntax to "EmbperlBlocks" to prevent Embperl from
> processing HTML-Tags
> http://www.ecos.de/embperl/pod/doc/Config.-page-2-.htm#sect_62

Thanks for that - I was under the impression that this was file-wide
rather than something that could be selectively applied in blocks.

ie, you're saying that you can do

<normal embperl-processed form entries>
...
[$ syntax EmbperlBlocks $]
<select name="dont_touch_me_embperl">...</select>
[$ syntax Embperl $]
...

Nice.

Cheers,

Andrew


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org