Jump to content

jquery autocomplete multiple times with multiple input fields


Tanja

Recommended Posts

First, Happy X-Mas to all!


I want to do a form for entering dog-show results.

On first site of form the user is able to enter how many dogs for each class (there are youth and open class for example) he want to insert.

So on second site there will be formfields for every dog in every class, created with php.

User should be able to take dogname from jquery autocomplete - this works for multiple fields. But i need the according id to the dogname - and actual only one id is given - the first one is changing by choosing from autocomplete in next fields...

Data came from a json array like

0: {dogidindatabase: "9892", value: "Excalibur Khali des Gardiens de la Cour ",…}
dogidindatabase: "9892"
label: "<img src='../main/img/female.png' height='20'>Excalibur Khali des Gardiens de la Cour   "
value: "Excalibur Khali des Gardiens de la Cour   "
1: {dogidindatabase: "15942", value: "Excalibur from Bandit's World Kalli",…}
dogidindatabase: "15942"
label: "<img src='../main/img/male.png' height='20'>Excalibur from Bandit's World   Kalli"
value: "Excalibur from Bandit's World   Kalli"

all i need is inside ...


the script in form is

<script type='text/javascript'>
		//<![CDATA[
		$(function() {
		
				$(".dog").autocomplete({
				source: "xxx.php",
				minLength: 3,
				select: function(event, ui) {
					$('#dogidindatabase').val(ui.item.dogidindatabase);
					}
			});
			
			$["ui"]["autocomplete"].prototype["_renderItem"] = function( ul, item) {
				return $( "<li></li>" ) 
  				.data( "item.autocomplete", item )
  				.append( $( "<a></a>" ).html( item.label ) )
  				.appendTo( ul );
			};
	
		});
		//]]>
</script>

and the form looked like

<input type='text' name='dog' class='dog' value='".strip_tags(${'dogname' .($countbabymale+1)})."' size='35' data-required='true' /><br>
	
<input class='readonly' readonly='readonly' type='text' id='dogidindatabase' name='dogidindatabase' size='5'  />

I changed in script and form id='dogidindatabase' to class, but it doesn´t work.

 

Testsite is under http://www.wolfdog-database.com/show/insert_show.php?lang=de (only german at first) - Insert a number (higher than 1) under baby 3-6 (first box, the others are not working for testing); submit to get to page 2; you see all post-variables (for testing).

Try to insert a dogname in first input-field (choose "exc") and insert first one - the id is under dogname. In second dogname inputfield you can choose second dog - the id for the first one changes to id of seond one ....

 

How can i get both for every dog?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.