2

I was trying to append input tags on clicking a button and was successful. I refered to many links

append new rows and input tags using jQuery

JQuery Append javascript

Jquery appended input button doesn't function with .on(click)

But now the problem is i'm using these input tags in a form and was trying to send those input tag values to next page using form action. But i'm unable send the appended input element values.

**

jquery

$("#addshowtime").click(function(){

    $("<input type='time' value='' />")
     .attr("id", "showtime5")
     .attr("name", "show_timing5")
     .prependTo("#showtime");
    });

**

html

 <label><strong>Show Timing1</strong></label><input id="showtime1" type="time" name="show_timing1"  required/>
    <label><strong>Show Timing2</strong></label><input id="showtime2" type="time" name="show_timing2"  required/>
    <label><strong>Show Timing3</strong></label><input id="showtime3" type="time" name="show_timing3"  required/>
    <label><strong>Show Timing4</strong></label><input id="showtime4" type="time" name="show_timing4"  required/>

    &nbsp;&nbsp;&nbsp;<cfinput type="button" id="addshowtime" class="btn" onClick="addInput()" name="add" value="+" />
    &nbsp;&nbsp;&nbsp;<cfinput type="button" class="btn1" onClick="subInput()" name="sub" value="RESET" />
    <p id="showtime">
    </p>
3
  • Show your code to us and explain what exactly is the problem Commented Sep 11, 2013 at 8:01
  • Post the code that you had tried. Commented Sep 11, 2013 at 8:02
  • so whenever i click on addshowtime button a new input type=time will be appended.On submit the added input's value must be send to the next page Commented Sep 11, 2013 at 8:08

1 Answer 1

1

I can see from your code that you must be appending input tag with same id. It will cause an issue if you are capturing the values by detecting input tags by ID.

Sign up to request clarification or add additional context in comments.

2 Comments

k so can i use class instead
Hey thanks mate it served the purpose. I tried that using class instead and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.