Hi,
I have a series of textbox wired up with jQuery Autocomplete feature, there are 12 textbox in total.
is thr any way to avoid repetitive code,
Any help, i will be very thankful. -
$('#prod_rate_0').val("");
-
$('#vat_0').val("");
-
-
$('#prod_rate_1').val("");
-
$('#vat_1').val("");
-
-
$('#prod_rate_2').val("");
-
$('#vat_2').val("");
-
-
$('#prod_rate_3').val("");
-
$('#vat_3').val("");
-
-
$('#prod_rate_4').val("");
-
$('#vat_4').val("");
-
-
$('#prod_rate_5').val("");
-
$('#vat_5').val("");
-
-
$('#prod_rate_6').val("");
-
$('#vat_6').val("");
-
-
$('#prod_rate_7').val("");
-
$('#vat_7').val("");
-
-
$('#prod_rate_8').val("");
-
$('#vat_8').val("");
-
-
$('#prod_rate_9').val("");
-
$('#vat_9').val("");
-
-
$('#prod_rate_10').val("");
-
$('#vat_10').val("");
-
-
$('#prod_rate_11').val("");
-
$('#vat_11').val("");
-
-
$("#prod_code_0").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_0').val(ui.item.prod_rate);
-
$('#vat_0').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_1").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_1').val(ui.item.prod_rate);
-
$('#vat_1').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_2").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_2').val(ui.item.prod_rate);
-
$('#vat_2').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_3").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_3').val(ui.item.prod_rate);
-
$('#vat_3').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_4").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_4').val(ui.item.prod_rate);
-
$('#vat_4').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_5").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_5').val(ui.item.prod_rate);
-
$('#vat_5').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_6").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_6').val(ui.item.prod_rate);
-
$('#vat_6').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_7").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_7').val(ui.item.prod_rate);
-
$('#vat_7').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_8").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_8').val(ui.item.prod_rate);
-
$('#vat_8').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_9").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_9').val(ui.item.prod_rate);
-
$('#vat_9').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_10").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_10').val(ui.item.prod_rate);
-
$('#vat_10').val(ui.item.vat);
-
}
-
});
-
-
$("#prod_code_11").autocomplete({
-
source: "prod_rpc.php",
-
minLength: 2,
-
select: function(event, ui) {
-
$('#p_id').val(ui.item.p_id);
-
$('#prod_rate_11').val(ui.item.prod_rate);
-
$('#vat_11').val(ui.item.vat);
-
}
-
});
-
2 2082 Rabbit 12,516
Recognized Expert Moderator MVP
You could use a for loop.
Best idea would be make an array of what you want then loop as mentioned above.
However, you could try something cleaner and simpler: jQuery UI AutoComplete.
Just make an array of what suggestions you want ( or dynamically create them ), then just: - $("#textBox").autocomplete({source: suggestionsArray});
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mudge |
last post by:
Please, someone, tell me why OO in PHP is better than procedural.
|
by: deko |
last post by:
I have 3 files I need to write to - and need to make sure I have a lock on
each, and take action if I can't get a lock. The code below works, but I
know it could be more efficient if I used a...
|
by: Cardman |
last post by:
Greetings,
I am trying to solve a problem that has been inflicting my self
created Order Forms for a long time, where the problem is that as I
cannot reproduce this error myself, then it is...
|
by: tshad |
last post by:
I am just trying to decide whether to split my code and uses code behind. I
did it with one of my pages and found it was quite a bit of trouble.
I know that most people (and books and articles)...
|
by: jsceballos |
last post by:
Hello.
I'm writing a proxy class, i.e: a class whose methods mostly delegate
their functionality to other class object. Most of the methods (which
are quite a lot) defined in the class would end...
|
by: liketofindoutwhy |
last post by:
I am learning more and more Prototype and Script.aculo.us and got the
Bungee book... and wonder if I should get some books on jQuery (jQuery
in Action, and Learning jQuery) and start learning about...
|
by: thj |
last post by:
Hi.
I've got this form that I'm trying to validate:
<form id="periodForm" action="" method="post">
<p>
Periode:
<input id="startDate" name="startDate" type="text" size="7"
value="<%=...
|
by: spyderfusion02 |
last post by:
Hi there, I am trying to get the class names dynamically for the script below.
I am using the Pagination plugin. I have different class names that are created through PHP so need to get them using...
|
by: pradeepjain |
last post by:
hii.. i use cope like this
<td><a href='/login.php' id="view-user" >Pradeep</a></td>
and defauly jquery dialog code
<script type="text/javascript">
$(function() {...
|
by: oranoos3000 |
last post by:
hi
would you please help me , what is meaning of the below jquery statement
$('~ span:first',this).text();
i dont understand meaning of the ~ in jquery selector
thanks very much for all...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |