English 中文(简体)
修改隐藏参数并提交
原标题:Jquery Onclick Change hidden parameter and submit

我用php和jquery,我制作了一张 像这样的div 列表。

<div class="divclass" id="<?php echo $i-1;?>">  
    <a href=" <?php echo $this->url(array( controller => controller name , action => action name ));?>">
    <span>Date: </span>
    </a>
</div>

我的 Javasctipt 脚本是, 我选择了 ID 的名称, 我点击了 ID 的名称, 我把隐藏参数设置为 id 的名称, 我想提交表单

<script type="text/javascript">
    $(document).ready(function() {
        $( .divclass ).click(function(){
            var idarray = $(this).attr("id");   
            document.getElementById( testo ).value=idarray;
            document.forms["prova"].submit();
        });
    });

形式是:

<form id="prova"  method="post"  action="<?php echo Zend_Controller_Front::getInstance()->getBaseUrl(). /controller-name/action-name ;?>">
<input type="hidden" value="" id="testo">
</form>
</script>

但是在下一页上,我没有邮箱参数。

最佳回答

您需要给 name 属性给 , 然后尝试 :

e. 如 等

<input type="hidden" value="" id="testo" name="testo">

您的表单在 标签之内, 将其放置在 标签之外 。

并写下DOM内部的代码,

  <script type="text/javascript">

    $(function() {
        // after DOM ready
         $( .divclass ).click(function(){
              var idarray = $(this).attr("id"); // or this.id do the same thing  
              $( #testo ).val(idarray); // set value to testo
              $("form#prova").submit(); // submit the form
          });
    });
 </script>
问题回答

暂无回答




相关问题
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.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签