oncklick with ID

Discussion in 'HTML' started by Jan Novak, Jun 17, 2013.

  1. Jan Novak

    Jan Novak Guest

    Hello,

    a have a (php/html) Form with multiple Buttons und multiple input fields.
    The Buttons and Fields are generated like this

    (php code)
    echo '<input name="USERNAME_'.$id.'" class="Feld" value="'
    ..$record['USERNAME']. '" autocomplete="off" >';


    Now i want, that if i click on a button, that one of the filed is filled
    up with some data.

    (php code)
    echo '<input type="button" name="zeige" class="Button" value="Show"
    onclick="this.form.USERNAME_'.$id.'.value=\''.$record['USERNAME'].'\'">
    ';
    This function is only working, if the Textfiled is named without the
    "id" extension (like 'Username" and not 'Username_'.$id)

    Anybody know a solution for this ?

    Jan
    Jan Novak, Jun 17, 2013
    #1
    1. Advertising

  2. Jan Novak

    TK Guest

    On 6/17/2013 7:02 AM, Jan Novak wrote:
    > Hello,
    >
    > a have a (php/html) Form with multiple Buttons und multiple input fields.
    > The Buttons and Fields are generated like this
    >
    > (php code)
    > echo '<input name="USERNAME_'.$id.'" class="Feld" value="'
    > .$record['USERNAME']. '" autocomplete="off" >';
    >
    >
    > Now i want, that if i click on a button, that one of the filed is filled
    > up with some data.
    >
    > (php code)
    > echo '<input type="button" name="zeige" class="Button" value="Show"
    > onclick="this.form.USERNAME_'.$id.'.value=\''.$record['USERNAME'].'\'">
    > ';
    > This function is only working, if the Textfiled is named without the
    > "id" extension (like 'Username" and not 'Username_'.$id)
    >
    > Anybody know a solution for this ?
    >
    > Jan

    My first thought is that the value of $id is not properly set at the
    point you are trying to use it. echo "USERNAME_'.$id.'" - it looks as
    if you will get something like username_extension, no .

    --
    TK ~ aka Terry Kimpling
    http://wejuggle2.com/video.php
    Soon to be called "Tricks I could do when I was only 65!"
    TK, Jun 17, 2013
    #2
    1. Advertising

  3. Jan Novak

    Tim Streater Guest

    In article <kpmts0$5ai$>,
    Jan Novak <> wrote:

    > Hello,
    >
    > a have a (php/html) Form with multiple Buttons und multiple input fields.
    > The Buttons and Fields are generated like this
    >
    > (php code)
    > echo '<input name="USERNAME_'.$id.'" class="Feld" value="'
    > .$record['USERNAME']. '" autocomplete="off" >';
    >
    >
    > Now i want, that if i click on a button, that one of the fields is filled
    > up with some data.
    >
    > (php code)
    > echo '<input type="button" name="zeige" class="Button" value="Show"
    > onclick="this.form.USERNAME_'.$id.'.value=\''.$record['USERNAME'].'\'">
    > ';
    > This function is only working, if the Textfiled is named without the
    > "id" extension (like 'Username" and not 'Username_'.$id)
    >
    > Anybody know a solution for this ?


    You can't do that with PHP; it's not running in the user's browser.

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
    Tim Streater, Jun 17, 2013
    #3
  4. Tim Streater <> writes:

    > In article <kpmts0$5ai$>,
    > Jan Novak <> wrote:
    >>
    >> a have a (php/html) Form with multiple Buttons und multiple input fields.
    >> The Buttons and Fields are generated like this
    >>
    >> (php code)
    >> echo '<input name="USERNAME_'.$id.'" class="Feld" value="'
    >> .$record['USERNAME']. '" autocomplete="off" >';
    >>
    >>
    >> Now i want, that if i click on a button, that one of the fields is
    >> filled up with some data.
    >>
    >> (php code)
    >> echo '<input type="button" name="zeige" class="Button" value="Show"
    >> onclick="this.form.USERNAME_'.$id.'.value=\''.$record['USERNAME'].'\'">
    >> ';
    >> This function is only working, if the Textfiled is named without the
    >> "id" extension (like 'Username" and not 'Username_'.$id)
    >>
    >> Anybody know a solution for this ?

    >
    > You can't do that with PHP; it's not running in the user's browser.


    The OP is trying to do it with some client-side scripting generated by
    PHP.

    To the OP: Posting PHP adds a level of uncertainty about what's actually
    going on. What do the two input element look like in the generated
    document?

    A simple test with these two code fragments used in isolation works for
    me, so the problem is somewhere else -- very likely in some other part
    of the PHP as has already been suggested.

    --
    Ben.
    Ben Bacarisse, Jun 17, 2013
    #4
  5. Jan Novak

    Jan Novak Guest

    Am 17.06.2013 16:33, schrieb Ben Bacarisse:

    >>> a have a (php/html) Form with multiple Buttons und multiple input fields.
    >>> The Buttons and Fields are generated like this
    >>>
    >>> (php code)
    >>> echo '<input name="USERNAME_'.$id.'" class="Feld" value="'
    >>> .$record['USERNAME']. '" autocomplete="off" >';
    >>>
    >>>
    >>> Now i want, that if i click on a button, that one of the fields is
    >>> filled up with some data.
    >>>
    >>> (php code)
    >>> echo '<input type="button" name="zeige" class="Button" value="Show"
    >>> onclick="this.form.USERNAME_'.$id.'.value=\''.$record['USERNAME'].'\'">
    >>> ';
    >>> This function is only working, if the Textfiled is named without the
    >>> "id" extension (like 'Username" and not 'Username_'.$id)


    > A simple test with these two code fragments used in isolation works for
    > me, so the problem is somewhere else -- very likely in some other part
    > of the PHP as has already been suggested.


    OK, so i try to search in the resulting HTML Page (source view).
    Because it will be always redirect to a ssl site, i must change this,
    before i can browse the source.

    Jan
    Jan Novak, Jun 17, 2013
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page