如何在 FBML/FBJS 中按名称选择元素?
我有下面的表格:
<form fbcontext="65d93ec1624a" id="app23744633048_frmFBNewsletter" action="http://register.stage.creative.com/Api/Facebook/SubscribeNewsletter" method="post"><input type="hidden" value="117533374986109" name="fb_sig_profile"><input type="hidden" value="1" name="fb_sig_is_admin"><input type="hidden" value="PAGE" name="fb_sig_type"><input type="hidden" value="0" name="fb_sig_is_fan"><input type="hidden" value="en_US" name="fb_sig_locale"><input type="hidden" value="1" name="fb_sig_in_new_facebook"><input type="hidden" value="1295493683.2974" name="fb_sig_time"><input type="hidden" value="0" name="fb_sig_added"><input type="hidden" value="sg" name="fb_sig_country"><input type="hidden" value="117533374986109" name="fb_sig_page_id"><input type="hidden" value="1" name="fb_sig_page_added"><input type="hidden" value="d2182fe10890bbfe8002bbdb6b6954ab" name="fb_sig_api_key"><input type="hidden" value="23744633048" name="fb_sig_app_id"><input type="hidden" value="7eaa52ce1dab5341d230cbd6b6bd42a8" name="fb_sig">
</form>
我需要检索 fb_sig_country。 我尝试了 javascript getelementsbyname 但这似乎在 FBJS 中不受支持。
我也尝试过 getchildnodes 方法,但仍然无法获取该值。
<script>
<!--
var countrycode = document.getElementById('frmFBNewsletter').getChildNodes()[8].getName();
function changeCountry(frmID){
var msgdialog = new Dialog();
msgdialog.showMessage('Error', countrycode);
}
-->
</script>
任何帮助将不胜感激:)
i have this form below:
<form fbcontext="65d93ec1624a" id="app23744633048_frmFBNewsletter" action="http://register.stage.creative.com/Api/Facebook/SubscribeNewsletter" method="post"><input type="hidden" value="117533374986109" name="fb_sig_profile"><input type="hidden" value="1" name="fb_sig_is_admin"><input type="hidden" value="PAGE" name="fb_sig_type"><input type="hidden" value="0" name="fb_sig_is_fan"><input type="hidden" value="en_US" name="fb_sig_locale"><input type="hidden" value="1" name="fb_sig_in_new_facebook"><input type="hidden" value="1295493683.2974" name="fb_sig_time"><input type="hidden" value="0" name="fb_sig_added"><input type="hidden" value="sg" name="fb_sig_country"><input type="hidden" value="117533374986109" name="fb_sig_page_id"><input type="hidden" value="1" name="fb_sig_page_added"><input type="hidden" value="d2182fe10890bbfe8002bbdb6b6954ab" name="fb_sig_api_key"><input type="hidden" value="23744633048" name="fb_sig_app_id"><input type="hidden" value="7eaa52ce1dab5341d230cbd6b6bd42a8" name="fb_sig">
</form>
and i need to retrieve the fb_sig_country.
i try the javascript getelementsbyname but that doesn't seems to be supported in FBJS.
i've also try the getchildnodes method but still can't get the value.
<script>
<!--
var countrycode = document.getElementById('frmFBNewsletter').getChildNodes()[8].getName();
function changeCountry(frmID){
var msgdialog = new Dialog();
msgdialog.showMessage('Error', countrycode);
}
-->
</script>
any help would be more appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有人想知道我如何解决这个问题,我发现当表单提交时,所有这些值实际上都会发布到服务器端。
我可以通过 firebug 查看这些值,因此我不需要在客户端手动检索这些值:)
in case anybody was wondering how i resolved this issue, what i found out was that all of these values are actually posted over to the server side when the form submits.
i can see those values via firebug, thus there was no need for me to manually retrieve those values on the client side :)