javascript parameter passing?

I am not quite sure how to describe what I want, but here goes nothing.

I am trying to have multiple buttons that will show/hide a div (I have that part set up already). I would like the button to have two values (number and letter) that will then fill in a parameter for another button's onclick event (these need to change however depending on what button was originally clicked.

For example, I click button1 which has values a and 1. This then fills in the parameters for the onclick event for button 3. Or I can click button 2 which has b and 2 and this will fill in b and 2 for the parameters for button 3 (so button 3 on click parameters need to change)

<input type='button' value="1" id="1" name="1" onclick="toggle();" style="background-color:lightblue; height:75px; width:75px;-webkit-appearance: none; border-radius: 70px;
" />  

That button is what needs to have the two "values" of some sort Hamburger

That's the button that needs the values passed to the event.

var toggle = function() {
    var mydiv = document.getElementById('table1');
    if (mydiv.style.display === 'block' || mydiv.style.display === '')
        mydiv.style.display = 'none';
    else
        mydiv.style.display = 'block'
}

Answers


It sounds to me like some having the function set some global variables would do the trick. Not entirely sure of what you're trying accomplish:

You can pass whatever parms you want to toggle:

<input type='button' value="1" id="1" name="1" onclick="toggle(1, a)" /> 

Need Your Help

CSS transition snaps on left side when max-width changes

html css twitter-bootstrap twitter-bootstrap-4 bootstrap-4

I have a simple '.full-width' class that I'm adding and removing to a &lt;nav&gt; when the user scrolls past a banner. The goal is to gradually expand or shrink the &lt;nav&gt; when the user scrolls

Remove Extraneous Semicolons in C# Using Roslyn - (replace w empty trivia)

c# .net roslyn

I've figured out how to open a solution and then iterate through the Projects and then Documents. I'm stuck with how to look for C# Classes, Enums, Structs, and Interfaces that may have an extraneous