On Wed, Mar 18, 2009 at 1:09 PM, lucas <[email protected]> wrote:
>
> Hi Brian, thanks for your answer. The matter here is that i can
> generate the elements dinamically but i´m not able to generate their
> names dinamically, all the new input fields generated has the same
> name and same ID... so, i want to to concatenate in the name of the
> input field a variable number generated with jquery. Appending that
> php code inside a div isn´t a problem, i think it is more a sintax
> problem...
> this is what a i´m trying to do:
>
> this code works fine:
> $("#newFormField").append('<?php echo $form->input('SNMPname',array
> ('label'=>'Name'));?>');

How could that possibly work? You are writing PHP code using
javascript, which runs in thebrowser. Browsers don't parse PHP code.

You should be writing form elements with javascript. There's no point
in trying to use Cake's FormHelper as it doesn't live inside the
browser. Do something like this:

$("#newFormField").append('<input name="...');


> suppose that ID is my global jquery variable, so, and of course this
> throw me an error:
> $("#newFormField").append('<?php echo $form->input('SNMPname'.ID,array
> ('label'=>'Name'));?>');

This also makes no sense. You're mixing up PHP and javascript. Aside
from what I said above, you're trying to append ID (a javascript var)
using PHP's dot (.) notation.

> so, how can i add this ID to the name of the new input field. before
> the php code is executed?

You need to step back and think about the order of operations here.
And forget entirely about using FormHelper to create the new inputs.
Your jquery code should be appending the raw HTML elements.

Again, though, I can't really offer specific advice without knowing
what it is you're trying to achieve. Why do you want the inputs to
have the same name & ID? Perhaps it would be easiest if you posted a
sample of an HTML input PLUS an example of one or more of these new
inputs that you want. Something like:

before javascript runs:
<input name="...

after javascript:
<input name="...
<input name="...
<input name="...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to