how to assign value to a button's name from a function

J

john_woo

Hi,

I'm wondering whether the following is possible:

function getName()
return "a name";

<input type=button onclick="a_function();" value="getName();" />

what I want is to assign the button's name value from calling a
function.
 
L

Lee

john_woo said:
Hi,

I'm wondering whether the following is possible:

function getName()
return "a name";

<input type=button onclick="a_function();" value="getName();" />

what I want is to assign the button's name value from calling a
function.

<input type=button onclick="a_function();" value="getName();" />

No. The HTML parser doesn't execute Javascript.
What are you really trying to do? It's hard to tell because
a) if the input has a NAME attribute, it will be accessible
by anything that can see the VALUE attribute.
b) the input in your example doesn't even have a NAME attribute.


--
 
A

ASM

john_woo a écrit :
Hi,

I'm wondering whether the following is possible:

function getName()
return "a name";

<input type=button onclick="a_function();" value="getName();" />

<input type=button name="myButton" value="getName"
onclick="this.value = this.value=='getName'?
'sendName' : 'getName';
a_function();" />
what I want is to assign the button's name value from calling a
function.

a_function(something) {
do some work
....
var b = document.myForm.myButton;
b.value = b.value=='getName'? 'sendName' : 'getName';
}
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top