Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Auto click not working

veena

New Coder
JavaScript:
$(".safeplus").click(function(){
    var id = $(this).attr('id');
    var row_id=id.split('_');
    row_id = row_id[1];
    next_row = Number(row_id)+1;
    $('#safediv_'+next_row).slideDown();
    $(this).fadeOut();
  });
});
  function myFunction() {
      //alert("myfuntion");
      $(".safeplus").click();
}
I have + button to generate new record on click of plus. but I should add new record without button click. So I am making auto click. On auto click instead of generating each row one by one, all records are generating at a time.
 

Attachments

  • Capture.PNG
    Capture.PNG
    19.2 KB · Views: 2
Last edited by a moderator:
In line 9, I'm not sure )}; should be there.

Also wdym autoclick?
Thank you, There was another function closing on line 9. that is ok. about autoclick, I have + button to generate new row. Ex: After I enter values in dropdown of safedrop 1 row and clicking +button, safedrop 2 should populate. and so on till safedrop6.
Now i need to eliminate + button. so that onchange of dropdown, new row should populate.
 
Ok, can I see you HTML?
HTML:
<div class="col-sm-2">
                        <div class="inputWithIcon">
                           <select class="form-control dropdown_custom text-uppercase time"  name="time_1" id="time_1" data-toggle="tooltip" data-placement="bottom"  data-trigger="manual"  onchange="myFunction()">
                                <option value="AM">AM</option>
                                <option value="PM">PM</option>
                           </select>
                          <!-- <input type="text" class="form-control input_custom time" name="time_1" id="time_1" placeholder="HH:MM AM/PM" value=""> -->
                          <i class="fas fa-plus safeplus safeplus_1" id="safeplus_1" aria-hidden="true" style="display: none;"></i>
                        </div> 
                      </div>
                   </div>
                   </div>
                   <?php for($i=2;$i<=6;$i++){?>
                     <div id="safediv_<?php echo $i;?>" style="display: none;" class="rowdiv">
                      <div class="row d-flex justify-content-center align-items-center mb-3 online_row">
                      <div class="col-sm-2 text-center">
                        <label>Safe Drops <?php echo $i;?></label>
                        <input type="hidden" name="safedrops_<?php echo $i;?>" value="Safe Drop <?php echo $i;?>">
                      </div>
                      <div class="col-sm-2">
                        <input type="text" class="form-control input_custom amount input_style" placeholder="$0.00" id="amount_<?php echo $i;?>" name="amount_<?php echo $i;?>">
                        <input type="hidden" name="amt_<?php echo $i;?>" value="" >
                      </div>
                      <div class="col-sm-2">
                        <div class="inputWithIcon">
                           <select class="form-control dropdown_custom text-uppercase time"  name="time_<?php echo $i;?>" id="time_<?php echo $i;?>" data-toggle="tooltip" data-placement="bottom"  data-trigger="manual" onchange="myFunction()">
                              <option value="PM">PM</option>
                                <option value="AM">AM</option>
                           </select>
                        <!-- <input type="text" class="form-control input_custom time" name="time_<?php echo $i;?>"  id="time_<?php echo $i;?>" placeholder="AM/PM" value=""> -->
                          <i class="fas fa-plus safeplus safeplus_<?php echo $i;?>" id="safeplus_<?php echo $i;?>" aria-hidden="true" style="display: none;"></i>
                        </div>
                      </div>
                   </div>
                   </div>
                   <?php }?>
 
HTML:
<div class="col-sm-2">
                        <div class="inputWithIcon">
                           <select class="form-control dropdown_custom text-uppercase time"  name="time_1" id="time_1" data-toggle="tooltip" data-placement="bottom"  data-trigger="manual"  onchange="myFunction()">
                                <option value="AM">AM</option>
                                <option value="PM">PM</option>
                           </select>
                          <!-- <input type="text" class="form-control input_custom time" name="time_1" id="time_1" placeholder="HH:MM AM/PM" value=""> -->
                          <i class="fas fa-plus safeplus safeplus_1" id="safeplus_1" aria-hidden="true" style="display: none;"></i>
                        </div>
                      </div>
                   </div>
                   </div>
                   <?php for($i=2;$i<=6;$i++){?>
                     <div id="safediv_<?php echo $i;?>" style="display: none;" class="rowdiv">
                      <div class="row d-flex justify-content-center align-items-center mb-3 online_row">
                      <div class="col-sm-2 text-center">
                        <label>Safe Drops <?php echo $i;?></label>
                        <input type="hidden" name="safedrops_<?php echo $i;?>" value="Safe Drop <?php echo $i;?>">
                      </div>
                      <div class="col-sm-2">
                        <input type="text" class="form-control input_custom amount input_style" placeholder="$0.00" id="amount_<?php echo $i;?>" name="amount_<?php echo $i;?>">
                        <input type="hidden" name="amt_<?php echo $i;?>" value="" >
                      </div>
                      <div class="col-sm-2">
                        <div class="inputWithIcon">
                           <select class="form-control dropdown_custom text-uppercase time"  name="time_<?php echo $i;?>" id="time_<?php echo $i;?>" data-toggle="tooltip" data-placement="bottom"  data-trigger="manual" onchange="myFunction()">
                              <option value="PM">PM</option>
                                <option value="AM">AM</option>
                           </select>
                        <!-- <input type="text" class="form-control input_custom time" name="time_<?php echo $i;?>"  id="time_<?php echo $i;?>" placeholder="AM/PM" value=""> -->
                          <i class="fas fa-plus safeplus safeplus_<?php echo $i;?>" id="safeplus_<?php echo $i;?>" aria-hidden="true" style="display: none;"></i>
                        </div>
                      </div>
                   </div>
                   </div>
                   <?php }?>
Thanks again, I used PHP also.
 

New Threads

Buy us a coffee!

Back
Top Bottom