服务器端表单的Javascript? [英] Javascript for a form on the server-side?

查看:62
本文介绍了服务器端表单的Javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题来自与克里斯托夫(Christoph)在我的最后一个问题中的讨论和安德鲁的另一种方法.

The question emerges from the discussion with Christoph in my last question 'HTML: target="_blank" for a drop-down list' and the alternative method by Andrew.

问题:由于某些用户缺乏Javascript支持,因此在服务器端运行代码.情况类似于此处.

Problem: to run code server-side because some users lack Javascript support. The situation is a form like here.

一些建议:

Christoph 的建议:

<form action="path-to-redirection-script" method="GET" target="_blank"
 onsubmit="window.open(this.elements['foo'].value); return false;">
 <select name="foo" size="1">
  <option value="http://google.com">google</option>
 </select>
 <input type="submit" value="go">
</form>

Andrew的另一种方法:

<form onsubmit="this.js_enabled.value=1;return true;">
    <input type="hidden" name="js_enabled" value="0">
    <input type="submit" value="go">
</form>

问题:在表单的情况下,如何处理服务器端脚本?

Question: How would you do the server-side scripting in the case of form?

推荐答案

实际上,这取决于要使用的服务器端语言.

Actually, it depends on the server-side language you're going to use.

但是,这就像读取表单为您提供的POST和GET值中的值一样简单.

But, it's as simple as reading out the values in the POST and GET Values the Form delivers you.

即PHP:

if($_POST["js_enabled"] == 0)  
{  
   doSomething(); // Redirecting   
}

但不要忘记验证所有值.

But don't forget to validate all values.

祝你好运,
拉伊特

good luck,
rAyt

修改

你去了(虽然答案很好)

There you go (pretty good answer though)

如何在Python中处理POST和GET变量? /a>

How are POST and GET variables handled in Python?

这篇关于服务器端表单的Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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