Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

oncklick with ID

7 views
Skip to first unread message

Jan Novak

unread,
Jun 17, 2013, 8:02:08 AM6/17/13
to
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

TK

unread,
Jun 17, 2013, 9:05:43 AM6/17/13
to
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!"
Message has been deleted

Ben Bacarisse

unread,
Jun 17, 2013, 10:33:30 AM6/17/13
to
Tim Streater <timst...@greenbee.net> writes:

> In article <kpmts0$5ai$1...@news.albasani.net>,
> Jan Novak <bfo...@yahoo.de> 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.

Jan Novak

unread,
Jun 17, 2013, 10:37:56 AM6/17/13
to
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

0 new messages