logo
down
shadow

Change button value on td click


Change button value on td click

By : Alessandro Mainas
Date : November 22 2020, 11:05 AM
help you fix your problem I currently have a table with blank
s. Each time a is clicked, it changes its background color. I want to change the value of rcStatus button along with the colors. Here's my current code: , This should do the job, but it's bad style to use ids more than once.
code :
<script>
    $('#table td').click(
      function(){
          var cell = $(this);
          state = cell.data('state') || 'first';

      switch(state){
          case 'first':
          cell.addClass('red');
          cell.data('state', 'second');
          this.getElementsByTagName('input')[0].value = "missed";
          break;
        // other cases here 
      }
    });
</script>
var table = document.getElementById("table");
var tds = table.getElementsByTagName("td");
for(var i = 0; i < tds.length;i++ ){
    tds[i].addEventListener("click", function(){
        var that = this;
        that.getElementsByTagName("input")[0].value = "missed";
    }, false);
}


Share : facebook icon twitter icon
Windows requires a click to activate a window before a second click will select a button. How can I change this?

Windows requires a click to activate a window before a second click will select a button. How can I change this?


By : user2198365
Date : March 29 2020, 07:55 AM
This might help you Well, I ended up finding my own solution that it pretty simple. I derive my own ToolStrip class (and MenuStrip class) as follows:
code :
// This version of ToolStrip enables mouse click's even when the main form is NOT active.
private class MyToolStrip : ToolStrip
{
    const uint WM_LBUTTONDOWN = 0x201;
    const uint WM_LBUTTONUP   = 0x202;

    static private bool down = false;

    protected override void WndProc(ref Message m)
    {
        if (m.Msg==WM_LBUTTONUP && !down) {
            m.Msg=(int)WM_LBUTTONDOWN; base.WndProc(ref m);
            m.Msg=(int)WM_LBUTTONUP;
            }

        if (m.Msg==WM_LBUTTONDOWN) down=true;
        if (m.Msg==WM_LBUTTONUP)   down=false;

        base.WndProc(ref m);
    }
}
how to change style of button on click and click on different button it should be change to default

how to change style of button on click and click on different button it should be change to default


By : Eoin Ryan
Date : March 29 2020, 07:55 AM
this will help IDs need to be unique so I removed the IDs from the rows.
I also moved the inline CSS to a stylesheet.
code :
<tr>
  <td>
    <button class="btn" >{{$table->table_no}} </button>
  </td>
 </tr>
$(function() {
  $('#table button').on("click",function(e){
    e.preventDefault();
    $('#table button').removeClass("selected");
    $(this).addClass("selected");
  });
});  
#table th,td { text-align: center; }
.selected { background-color:green }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table id="table" class="table">
  <thead>
   <tr>
      <th>Tables</th>
   </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        <button class="btn" >{{$table->table_no}} </button>
      </td>
     </tr>
    <tr>
      <td>
        <button class="btn" >{{$table->table_no}} </button>
      </td>
     </tr>
    <tr>
      <td>
        <button class="btn" >{{$table->table_no}} </button>
      </td>
     </tr>
    <tr>
      <td>
        <button class="btn" >{{$table->table_no}} </button>
      </td>
     </tr>

   </tbody>
 </table>
How to change button Image like toggle button RecyclerView button click programmatically

How to change button Image like toggle button RecyclerView button click programmatically


By : Johhny Sasaki
Date : March 29 2020, 07:55 AM
Hope this helps It will be better if you use selected as boolean variable into your pojo class, it will help adapter to set the image according to state. Actually , whenever you scroll-up and down un-visible items remove from the memory, and we have updated our list according to the button event, so second time it will fetch the desired state and again show the previous state image.
BuildCustomAdapter pass context always whenever you create an Adapter, context will help you
code :
 Context context;
    public BuildCustomAdapter(List<Build> buildList,Context context) {
            this.buildList = buildList;
            this.context = context;
        }
public class Build {
        private String name;
        private int images;
        private boolean selected;

        public Build(boolean selected, String name,int images) {
            this.images = images;
           this.selected=selected; 
           this.name = name;
        }

        public int getImages() {
            return images;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public void setSeleted(boolean selected){
            this.selected=selected;
        }

        public boolean isSelected(){
            return selected;
        } 
    }
@Override
        public void onBindViewHolder(MyViewHolder holder,  int position) {

            Build build = buildList.get(position);

            holder.imageView.setImageResources(build.getImages());

            holder.name.setText(build.getName());
            setImageIntoButton(holder.button,build.isSelected());

            holder.button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        build.setSelected(!build.isSelected());
                        setImageIntoButton(holder.button,build.isSelected());
                    }
                });
        }

      private void setImageIntoButton(Button buttonView,boolean isSelected){
         if(isSelected)
           buttonView.setBackgroundResource(R.drawable.clicked_image); 
            else 
          buttonView.setBackgroundResource(R.drawable.cross_image); 
 }
Build builddata = new Build(buildList.get(i).isSelected(), buildList.get(i).getName(),buildList.get(i).getImages());
First button click, change colour, Second click change font family

First button click, change colour, Second click change font family


By : Maurizio
Date : March 29 2020, 07:55 AM
To fix the issue you can do you have used = instead of ==.= are used for assignment and for compare you must use == or ===. also you don't need to move function and I moved it to go function
code :
var clicks = 0;
var a = document.getElementById("output");

function go() {
    clicks ++;
    if (clicks == 1) {
       a.style.color = "red";
 }
   if (clicks == 2) {
      a.style.fontFamily = "sans-serif";
  }
   if (clicks == 3) {
      a.innerText = a.innerText+a.innerText+a.innerText+a.innerText;
  }
   if (clicks == 4) {
      a.innerText = "done";
  }
};
<body>
<button onclick=go();>ClickMe</button>
<p id="output">Change Me</p>
</body>
Hide&Show Fieldset on Javascript using a button doesn't work on first click / How to change button title on click

Hide&Show Fieldset on Javascript using a button doesn't work on first click / How to change button title on click


By : user2465858
Date : March 29 2020, 07:55 AM
I wish did fix the issue. A button element doesn't have a title property so your test was failing. You need to check the button's textContent.
Also, don't use HTML comment syntax () inside of
shadow
Privacy Policy - Terms - Contact Us © festivalmusicasacra.org