English 中文(简体)
在多个投入领域的关键阶段如何改变价值?
原标题:How can i do to change value id when keyup on multiple input fields?
  • 时间:2012-01-12 04:27:52
  •  标签:
  • jquery
  • input

这部法典:

<input type="text" id="participant1"  name="name[1][]" value="Andi"/> </p>
<input type="text" id="idparticipant1" name="idparticipant[1][]" value="1001"/>

<input type="text" id="participant2"  name="name[2][]" value="Smith"/> </p>
<input type="text" id="idparticipant2" name="idparticipant[2][]" value="1005" />

页: 1

<script src="jquery-1.4.js"></script>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script>
$(document).ready(function()
{

    $( [id^="participant"] ).keyup(function()
{
      var txt = $(this).val();
      $.ajax({
  type: "POST",
  url: "blue.php",
  data: "nameparticipant=" + txt,
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(data)
  {
     $(this).next().val(data.d);
     //alert(data.d); 
  }
  //failure: failerEvent
});
});//keyup

 });
 </script>

蓝皮。 php

<?php
$nameparticipant=$_POST["nameparticipant"]);
$res = mysql_query("select * from table where upper(name) like  $nameparticipant% ");
$t=mysql_fetch_array($res);

echo"$t[nik]";
?>

除“安道尔”外,如果是参与者的关键投入名称,那么价值就变了0。 而当它再一次回头来时,它的价值就改变了。

可以做些什么?

最佳回答

用途

var txt = $(this).val();

instead of

var txt=$(  [id^="participant"]  ).val();

remove unneccesory <p> tags from the code,

<input type="text" id="participant1"  name="name[1][]" value="Andi"/>
<input type="text" id="idparticipant1" name="idparticipant[1][]" value="1001"/>

<input type="text" id="participant2"  name="name[2][]" value="Smith"/> 
<input type="text" id="idparticipant2" name="idparticipant[2][]" value="1005" />

JavaScript,

$.ajax({
    type: "POST",
    url: "blue.php",
    data: "nameparticipant=" + txt,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data)
         {
            $(this).next().val(data.d); 
         }
});

rel=“nofollow”>workingshop

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签