Button Value...

1

116

Can the value of a button be changed 'onclick'? I am familiar with doing it
in VB, but in Java, I am missing it. I have a VB program with lots of common
formulas that people in the shop use, And normally I would have one button
'Calc' and change to 'Clear' onclick which would reset the fields.

David
 
R

Ronx

I would avoid using Java - it's disabled or not even installed on a
significant number of PCs - perhaps more than 50%.

You could use javascript. Give the button an id
<input type="submit" value="Calc" id="buttonid">
and then use something like

getElementById["buttonid"].value = "Clear" [Not tested]

--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 
J

Jon Spivey

You could use javascript. Give the button an id
<input type="submit" value="Calc" id="buttonid">
and then use something like

getElementById["buttonid"].value = "Clear" [Not tested]

Something like this
<input type="button" id="b" value="press" onclick="this.value = 'you pressed
me';" />
or

<input type="button" id="b" value="press" />
<script type="text/javascript">
document.getElementById("b").onclick = function(){this.value = 'you pressed
me';};
</script>

Both would do the same thing.

Cheers,
Jon
 
H

Hot-text

Jon Spivey I seen this Cold Code before!
Yes Ron Symonds JavaScript,,, But when David says Java I believe he saying
JavaScript!
and I like that linker for Debugs I put it in my Tool Box!


Jon Spivey said:
You could use javascript. Give the button an id
<input type="submit" value="Calc" id="buttonid">
and then use something like

getElementById["buttonid"].value = "Clear" [Not tested]

Something like this
<input type="button" id="b" value="press" onclick="this.value = 'you
pressed me';" />
or

<input type="button" id="b" value="press" />
<script type="text/javascript">
document.getElementById("b").onclick = function(){this.value = 'you
pressed me';};
</script>

Both would do the same thing.

Cheers,
Jon
--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 

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

Top