-1

I am trying to create a button that onclick changes from Migrate to migrated. When i Click on it , the value changes, but the display remains the same. How do i go back dealing with this situation

function migrate(p){
    $$('dlmisc_a10').value = "Migrated";
    alert ($$('dlmisc_a10').value);
}
1
  • 4
    What kind of button is it?
    – Musa
    Commented Jan 10, 2013 at 3:47

4 Answers 4

1

I'm going to assume that the button is a <button></button> and $$ returns an element with the passed id. Then to change the text you'll have to change the innerHTML.

function migrate(p){
    $$('dlmisc_a10').innerHTML = "Migrated";
}
1
  • Im sorry I should have been more specific, but you got this right. Very New to Javascript, so was really confused. Thanks again
    – rsharma
    Commented Jan 10, 2013 at 14:19
0

Assuming that you are using prototype (I can only guess that by your $$ function invocation) you can to this to change the button the button label:

$$('dlmisc_a10').first().update("Migrated");

Anyways is odd because I do not think "dlmisc_a10" is a valid selector. Can you post the portion of your html that has that button and clarify if you are using prototype or any other js fwk?

0

Assuming that you have declare button like this:

<input type="button" id='button1' value="M1" onclick="migrate();"></input>

Then if you write javascript as follows then it will change the value as you want:

<script type="text/javascript">
function migrate()
{
    document.getElementById("button1").value='M2';
    alert(document.getElementById("button1").value);
}
</script>
0

I think you are trying to do this.

HTML:

<input type="button" value="Migrate" onclick="migrate(this)"/>

JavaScript:

function migrate(p) {
    p.value = "Migrated";
    alert(p.value);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.