[thelist] changing submit button value with javascript

Joel D Canfield joel at streamliine.com
Tue Jul 31 14:10:25 CDT 2007


I'm trying to change the value of a submit button with javascript. when
the 'delete this item' checkbox is clicked, I want to toggle the value
of the submit button to 'Del', and when it's clicked again, toggle it
back to 'Save'

all that happens is the submit button is selected, but not changed

here's how I'm calling the function

    <input type="checkbox" name="delasset" id="delasset0"
onclick="toggleValue('submit0','delasset0','Save','Del');" />

here's submit0

    <input type="submit" name="submit" id="submit0" value="Save"
class="updformsubmit" />

and here's the javascript

    function toggleValue(toggleID,clickedID,val1,val2)
    {
        if (clickedID.checked == true)
        {
            document.getElementById(toggleID).value = val2;
        } else {
            document.getElementById(toggleID).value = val1;
        }
    }

this works to change the value when the checkbox is clicked, but of
course doesn't change it back, ever

    <input type="checkbox" name="delasset" id="delasset0"
onclick="submit0.value = 'Del';" />

what am I missing?

thanks

joel



More information about the thelist mailing list