duanbeng8872 2016-03-18 16:10
浏览 186
已采纳

从脚本添加的输入框中获取值

Better will be if you can see it. On my website Loloid

There is input box, where user write his username. In menu is region and there user choose his region, where he plays. When he choose his region, in form is new hidden input with your region.

I have PHP file, where i save his username with $_POST, but it doesn't work for region. Here are my codes, I have no idea how to save my region with $_POST

//.Value are classes for regions   
    $('.Value').click(function(e){
        var value = $(e.target).text();
        $('.hiddenRegion').html(value);
    });

Here is HTML

<form method="post" action="lol.php" id="form">
    <ul>
        <li class="field">
            <input class="input" type="text" autocomplete="off" placeholder="Write a summoner name" name="summonerName" id="summonerName"/>
            <a id="formSubmit"><i class="icon-search"></i></a>
            <input type="hidden" name="hiddenInput" class="hiddenRegion"></input>
        </li>
    </ul>
</form>

And PHP

$region = $_POST['hiddenInput'];

When i print $region with echo, it returns just blank string

  • 写回答

3条回答 默认 最新

  • duanbanfei2875 2016-03-18 16:17
    关注

    You are setting the input control values and not html.In-order to set or get input control values one should use val()

    It should be $('.hiddenRegion').val(value);

    and not $('.hiddenRegion').html(value);

    And to get values

     $('.hiddenRegion').val()
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器