oncklick with ID

J

Jan Novak

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
 
T

TK

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 .
 
T

Tim Streater

Jan Novak said:
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.
 
B

Ben Bacarisse

Tim Streater said:
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.
 
J

Jan Novak

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top