douhao7677 2015-12-15 17:33
浏览 47
已采纳

选择OnChange更改PHP变量

Hello StackOverflow People.

I need you help. I have this code:

<select name="type" onChange="idk?" class="form-control">
<option value="H">Week 51</option>
<option value="V">Week 52</option>
</select>

And if an user change the week i want to change the file get content :s

$Week = "";
echo file_get_contents('http://rooster.farelcollege.nl/'.$Week.'/c/c00050.htm');

Thanks!

greetings from the Netherlands =)

  • 写回答

1条回答 默认 最新

  • doulian7305 2015-12-15 17:41
    关注

    you can send Ajax request to the "file_get_contents" url. This is what I am using and it works fine :)

    <select name="type" class="form-control">
        <option value="H">Week 51</option>
        <option value="V">Week 52</option>
    </select>
    
    $(document).ready(function() {
      $( ".form-control" ).change(function() {
        $.ajax({
            data: {
                // You are not sending any post variables right? Then leave this empty :-) otherwise use it as array 'var1': 'value', 'var2': 'value2' ...
            },
            url: 'http://rooster.farelcollege.nl/'+$(this).val()+'/c/c00050.htm',
            method: 'POST',
            success: function(msg) {
                alert(msg); // Optional, show text that was given by URL, can be removed
            }
        });
      });   
    }); 
    

    jquery.com/jquery.ajax

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 github符合条件20分钟秒到账,github空投 提供github账号可兑换💰感兴趣的可以找我交流一下
  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?