0
I have an equipment control system. In this system, while the user fills in the form, he has the option to add another field to register another device that will be associated with a customer. To make this feature I used a code in javascript
<script type="text/javascript">
$(document).ready(function () {
var $link = $('#add_answer');
var $model = $link.prev('.equipamento');
$link.click(function () {
var $clone = $model.clone(false);
$(this).before($clone);
$clone.wrap('<div class="wrapper"></div>')
.after('<a href="javascript:void(0)" class="remove"></a>')
.addClass('added')
.parent()
.hide()
.fadeIn();
});
$('a.remove').live('click', function () {
$(this).parent().fadeOut('normal', function () {
$(this).remove();
});
});
});
</script>
How do I access form fields using Jquery.
Can you help me? Any suggestions? Am I doing it right? Is there a better way to do it?
note:I didn’t program this javascript
Could you translate his problem better?
– Guilherme Oderdenge
The system is made to know why equipment passes the cables here company. It does not have a fixed number of equipment, so the user inserts the tip A (from where the cable comes out), the equipment through which it passes, and the tip B (where the cable ends). As we do not know how many equipment have in this path, I inserted a button + to insert a new equipment (the user inserts as many as you want).
– jpklzm
So far so good, but then we need to consult these data. What I do not know how to do is that the system checks how many equipment it has registered and manages the fields for visualization. I don’t know how to call this clone created through code.
– jpklzm
The generation of fields for visualization you can use a loop (
for
for example) and add the fields with the registered values. At the end of the iteration, you add the link element with the required parameters.– ricidleiv
You could better exemplify your problem by adding as your table is in the database, because "inserted in the form of an array" it is not clear how the information is stored.
– ricidleiv
Welcome. Always try to explain the best possible in the question. For this there is the edition. It makes it easier for everyone to understand the problem and helps search engines index content and help other programmers.
– Maniero
Come on, in the code I posted, I’m generating clones. How do I access/call this clone by code? I want to know how I can refer to that clone within the code.
– jpklzm