如何发布由jquery动态创建的textbox值 [英] how do i post textbox value which is dynamically created by jquery

查看:137
本文介绍了如何发布由jquery动态创建的textbox值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用codeigniter框架我试图使用HTML窗体中的文本框,当用户单击按钮一个文本框将由jquery自动生成,但是当我提交表单其他文本框值正在发布正确,但我不能发布

 这里是jquery代码。 $(#button)。live('click',function add(){
$(#tblRel)。append(
'< tr>< td& $ b +'< input type =textclass =input_value_shortid =provaname =jquery_txtvalue =prova/>'+
'< / td>< tr> ;'
);
});

HTML:

 <?php echo form_open(validation / form_main);?> 
< table id =tblRelborder =0>
< tr>
< td class =lable>申请人姓名:< / td>
< td colspan =3><?php echo form_input(array('name'=>'applicant_name','class'=>'input_value_long','value'=> set_value ('applicant_name')))?>< / td>
< / tr>
< / table>
<?php echo form_submit(array('id'=>'submit','name'=>'Save','value'=>'Save record','class'=> 'button_print'));?>

在form_main()函数中我发布如下:

  form_main(){
$ name = $ this-> input-> post('applicant_name');
$ jquery_txt = $ this-> input-> post('jquery_txt');
}

我可以得到$ name的值,但$ jquery_txt为空
任何人都可以帮助我!对不起形成我可怜的英语。

解决方案

  $(#button)。live ('click',function add(){
$(#tblRel)。append('< tr>< td>< input type =textclass =input_value_shortid = jquery_txtname =jquery_txt []value =prova/>< / td>< tr>');
});

我想你的名字是不同的文本框。使它相同,如果你有更多比一个文本框将文本框的名称更改为数组,否则您在发布后只会得到一个值。


i am working with codeigniter framework i am trying to use textboxes in HTML form when the user click the button a textbox will automatically generated by jquery but when i submit the form the other textbox values are posting correctly but i can't post the jquery textbox value.

here is the jquery code:

  $("#button").live('click',function add(){ 
   $("#tblRel").append(
       '<tr ><td>'
    +'<input type="text" class="input_value_short" id="prova" name="jquery_txt" value="prova" />'+ 
       '</td><tr>'
   );
});

HTML:

  <?php echo form_open("validation/form_main");?>
  <table id="tblRel"  border="0">
      <tr>
          <td class="lable">Applicant Name:</td>
          <td colspan="3"><?php echo form_input(array('name'=>'applicant_name','class'=>'input_value_long','value'=>set_value('applicant_name'))) ?></td>
      </tr>
 </table>
 <?php echo form_submit(array('id'=>'submit','name'=>'Save','value'=>'Save record','class'=>'button_print'));?>

in the form_main() function i am posting like this:

    form_main(){
    $name        = $this->input->post('applicant_name');
    $jquery_txt  = $this->input->post('jquery_txt');
    }

i can get the value of $name but the $jquery_txt is empty can anyone help me please! and sorry form my poor english.

解决方案

      $("#button").live('click',function add(){ 
           $("#tblRel").append('<tr ><td><input type="text" class="input_value_short" id="jquery_txt" name="jquery_txt[]" value="prova" /></td><tr>');
       });

I guess your name and is are different for the textbox..Make it same and if you have more than one textbox change the name of the textbox into array otherwise you will get only one value after posting it.

这篇关于如何发布由jquery动态创建的textbox值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆