Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8564401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:11:30+00:00 2026-06-11T17:11:30+00:00

So I have been at this and have tried so many different things, I

  • 0

So I have been at this and have tried so many different things, I am hoping that I could get some help. I have the following form that I want to use. I understand all the backend access components etc, but I can’t seem to get the form to behave including timepicker, datepicker, autcomplete, and replicate. can someone find the bug(s) in my code? I have been banging my head against the wall for a while now. The replicate function also seems to have broken. Any Ideas?

Thanks!
Jon

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>

<script>
$(document).ready(function($) {
var drugs = [
"Atenolol (Tenormin)",
"Atropine",
"Atropine Ophthalmic Solution",
"Azathioprine (Imuran)",
"Azithromycin (Zithromax)",
"Benazepril (Fortekor)",
"Betaxolol and Levobetaxolol",
"Bethanechol (Urecholine, etc.)",
"Bisacodyl (Dulcolax)",
"Bismuth Subsalicylate (Pepto-Bismol)",
"Brinzolamide (Azopt)",
"Bromides",
"Buprenorphine (Buprenex)",
"Burow's Solution",
"Buspirone HCl (BuSpar)",
"Butorphanol Tartrate (Torbugesic, Torbutrol)",
"Calcitonin"];

    $(".autocomp").autocomplete({source:drugs});
        $( ".datepicker_txt" ).datepicker();
        $(".timePick_txt").timepicker({'step' : 15,
                                   'scrollDefaultNow': true });
    $("#btnAdd").click(function(){
        var $table =  $(document.getElementById('drug_treatment_table'));
        var $tr = $(document.getElementById('drug_treatment_table')).find('tr:last').clone(true);
        $tr.find('input').attr('id',function(){
            var parts = this.id.match(/(\D+)(\d+)$/);
            return parts[1]+ ++parts[2];
        }).attr('name',function(){
            var parts = this.name.match(/(\D+)(\d+)$/);
            return parts[1]+ ++parts[2];
        });
        $tr.find('select').attr('id',function(){
            var parts = this.id.match(/(\D+)(\d+)$/);
            return parts[1]+ ++parts[2];
        }).attr('name',function(){
            var parts = this.name.match(/(\D+)(\d+)$/);
            return parts[1]+ ++parts[2];
        });
        $tr.find(".datepicker_txt").datepicker();
        $tr.find(".autocomp").autocomplete({source:drugs});
        $tr.find(".timePick_txt").timepicker();
        $table.find("tr:last").after($tr);
        $(document.getElementById("numEntries")).attr('value',$table.rows.length-1);
    });
    $("#btnDel").click(function($){
        var $table = $(document.getElementById('drug_treatment_table'));
        var rowsNum = table.rows.length;
        if(rowsNum>2){
            $table.remove($table.find('tr:last'));
        }
    });
});
</script>
<link href="style/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css" />

</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <input type="button" name="btnAdd" id="btnAdd" value="Increase Drug Treatments"/>
<input type="button" name="btnDel" id="btnDel" value="Decrease Drug Treatments"/>
</form>
<form id="add_drugs" name="add_drugs" method="post" action="">
    <input type="hidden" name="numEntries" id="numEntries" value="1" />
    <table width="100%" border="1" name="drug_treatment_table" id="drug_treatment_table">
          <tr>
            <th width="3%" scope="col">#</th>
            <th width="14%" scope="col">Drug</th>
            <th width="32%" scope="col">Special Directions </th>
            <th width="18%" scope="col">Quantity</th>
            <th width="12%" scope="col">How Often</th>
            <th width="8%" scope="col">Starting</th>
            <th width="13%" scope="col">Finishing</th>
          </tr>
          <tr>
            <td>1</td>
            <td>
            <input type="text" name="drug_name_1" id="drug_name_1" class="autocomp"/></td>
            <td>
            <input name="special_driections_1" type="text" id="special_driections_1" size="60" /></td>
            <td nowrap="nowrap">
            <input type="text" name="quant_1" id="quant_1" />
            <select name="quant_unit_1" id="quant_unit_1">
              <option>cc</option>
              <option>mg</option>
              <option>g</option>
            </select></td>
            <td nowrap="true"><select name="how_often_drug_1" id="how_often_drug">
              <option>Q1hr</option>
              <option>Q2hr</option>
              <option>Q3hr</option>
              <option>QID</option>
              <option>TID</option>
              <option>BID</option>
              <option selected="selected">SID</option>
              <option>Q2 Day</option>
              <option>Q3 Day</option>
              <option>Q4 Day</option>
              <option>Q5 Day</option>
              <option>Q6 Day</option>
              <option>Q1 Week</option>
              <option>Q2 Week</option>
            </select><input type="text" id="start_time_1" class="timePick_txt" /></td>
            <td><input type="text" id="datepicker_start_drug_1" name="datepicker_start_drug_1" class="datepicker_txt"></td>
            <td><input type="text" id="datepicker_end_drug_1" name="datepicker_end_drug_1" class="datepicker_txt"></td>
          </tr>
        </table>
</form>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:11:31+00:00Added an answer on June 11, 2026 at 5:11 pm

    After playing with the code for a while, I think I was able to produce your desired outcome. Just a couple comments on your code.

    First, you could benefit from a refresher on how selectors work in jQuery. You are using javascript to grab elements and casting them as jQuery objects when you could simply use their selectors.

    Second, please make sure to proofread your code. There are numerous typos and misspellings that will cause problems in the future. I tried to fix as many as I could find.

    Here is a link to the fiddle: http://jsfiddle.net/jlange88/5594c/19/

    Some caveats:

    I simply created a long string to represent a new table row, you should devise some way to programmatically do this. Also, there is most certainly a better way to apply generic id’s to your new tables, I just don’t feel like implementing it now :).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on this for a while. Tried many many different things,
I've tried many different things, but I cant seem to get rid of this
So I have been battling this issue for awhile now and tried many different
I have done all kinds of research and tried many different things. I know
I have been staring at this code for few hours, tried walkthrough,debugging with autos
I have been stuck on this for a while. i have tried and I
Questions exactly like this have been asked before, i've read them all and tried
I tried endlessly now you resolve this utter frustrating situation I have been having.
I have tried making a fiddle for this, but it's been too difficult to
I have been using this code, but have been running into some memory issues:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.