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 2081
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: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |