php - Show a submit button on table row mouseover


First of all, forgive me for being a beginner to Javascript and PHP.

Second: I have a table with some order information, and the first cell of every row consists of a submit button that will send the information from that row to a second page where it will be displayed.

I wrote a small Javascript function so that the submit buttons are hidden until someone mouses over them. But my problem is that the submit ID for the buttons is assigned to the first button, so no matter what row I mouse over, only the first submit button displays.

The display function is the following:

    function showButton(id) 
        var e = document.getElementById(id);
        if( == 'block')
  = 'none';
  = 'block';

The row is defined as:

    tr onmouseover='showButton("submitButton");'

And the button which is generated on every iteration of a new row is:

    input type='submit' id='submitButton' value='Submit' 
                   style='cursor: pointer; display: none;' />

Any help would be greatly appreciated. I want the correct submit button appearing next to each row on mouseover.




That can be easily accomplished with just CSS, like this:

tr input { display: none; }
tr:hover input { display: inline; }

People are also looking for solutions to the problem: php - RegEx with optional part inside


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.