使用括号但不想拥有数组? [英] Using brackets but not wanting to have an array?
问题描述
您好亲爱的新闻组,
我的问题似乎有些愚蠢,但经过一些googeling,我找不到
的解决方案。重点是:
我有一个多选字段,我使用一些
JavaScript添加值。由于我愿意在以后的PHP
处理器中使用所有值,我必须调用这些选择字段,如name [],然后在
提交之前,我必须标记每个项目(JavaScript也是如此)
但似乎这对我来说在某种程度上是合乎逻辑的,好像javascript
不想处理像名字这样的变量[]因为它可能会使它像一个数组一样线程化它,因为它不是(至少不在那种情况下)。使用
name \ [\]也不会工作。
什么可行?
给一个我正在做的小事,请检查
http ://gosingen.dyndns.tv/sura/1/programm/addmovie.php 但请注意
仍然有很多混乱要清楚,编程可能
看起来很恶心。这是:)
提前感谢
Thorben
Hello dear Newsgroup,
my problem seems somehow silly, but after some googeling, I don''t find
a solution. The point is:
I have an multiple select field to which I add values using some
JavaScript. As I am willing to use all the values in a later PHP
processor, I have to call these select fields like name[] and before
submitting, I have to mark every item (JavaScript as well)
But it seems, which is in some way logical to me, as if the javascript
doesn''t want to process variables like name[] as it probably threads it
like an array, which it isn''t (at least not in that context). Using
name\[\] won''t work either.
What could work?
To give a small sneak of what I am doing, check
http://gosingen.dyndns.tv/sura/1/programm/addmovie.php but note that
there is still a lot of mess to be cleant, the programming proably
looks disgusting to you. It is :)
thanks in advance
Thorben
推荐答案
Thorben Grosser写道:
Thorben Grosser wrote:
你好亲爱的新闻组,
我的问题似乎有点傻,但经过一些googeling,我找不到
解决方案。重点是:
我有一个多选区域,我使用一些
JavaScript添加值。由于我愿意在以后的PHP
处理器中使用所有值,我必须调用这些选择字段,如name [],在提交之前,我必须标记每个项目(JavaScript也是如此)<但是看起来,这对我来说在某种程度上是合乎逻辑的,好像javascript
不想处理像name []这样的变量,因为它可能会像一个数组一样将它连接起来,它不是(至少不是在那种情况下)。使用
name \ [\]也不会工作。
什么可行?
Hello dear Newsgroup,
my problem seems somehow silly, but after some googeling, I don''t find
a solution. The point is:
I have an multiple select field to which I add values using some
JavaScript. As I am willing to use all the values in a later PHP
processor, I have to call these select fields like name[] and before
submitting, I have to mark every item (JavaScript as well)
But it seems, which is in some way logical to me, as if the javascript
doesn''t want to process variables like name[] as it probably threads it
like an array, which it isn''t (at least not in that context). Using
name\[\] won''t work either.
What could work?
如果您有表单控件,那么你想要包含
方括号的名称,它们可能类似于:
< form name =" blahForm" action ="">
< select name =" blahSelect []">
...
然后您可以使用以下方法访问它们:
var theSelect = document.forms [''blahForm'']。elements [''blahSelect []''];
阅读使用方括号的常见问题解答:
< URL:http://www.jibbering.com/faq>
[...]
-
Rob
If you have form controls that you want to have names that include
square brackets, they might look something like:
<form name="blahForm" action="">
<select name="blahSelect[]">
...
Then you can access them using:
var theSelect = document.forms[''blahForm''].elements[''blahSelect[]''];
Read the FAQ on using square brackets:
<URL:http://www.jibbering.com/faq>
[...]
--
Rob
Thorben Grosser在新闻中写道:1135853254.064098.260210
@ g44g2000cwa.googlegroups.com in comp.lang.javascript :
Thorben Grosser wrote in news:1135853254.064098.260210
@g44g2000cwa.googlegroups.com in comp.lang.javascript:
你好亲爱的新闻组,
我的问题似乎有点傻但是经过一些蠢事之后,我找不到解决方案。重点是:
我有一个多选区域,我使用一些
JavaScript添加值。由于我愿意在以后的PHP
处理器中使用所有值,我必须调用这些选择字段,如name [],在提交之前,我必须标记每个项目(JavaScript也是如此)<但是看起来,这对我来说在某种程度上是合乎逻辑的,好像javascript
不想处理像name []这样的变量,因为它可能会像一个数组一样将它连接起来,它不是(至少不是在那种情况下)。使用
name \ [\]也不会工作。
什么可行?
为了对我正在做的事情进行一次小小的探讨,请检查
http://gosingen.dyndns.tv/sura/1 /programm/addmovie.php 但请注意
仍然有很多乱七八糟的东西,编程可能看起来很令人厌恶。它是:)
Hello dear Newsgroup,
my problem seems somehow silly, but after some googeling, I don''t find
a solution. The point is:
I have an multiple select field to which I add values using some
JavaScript. As I am willing to use all the values in a later PHP
processor, I have to call these select fields like name[] and before
submitting, I have to mark every item (JavaScript as well)
But it seems, which is in some way logical to me, as if the javascript
doesn''t want to process variables like name[] as it probably threads it
like an array, which it isn''t (at least not in that context). Using
name\[\] won''t work either.
What could work?
To give a small sneak of what I am doing, check
http://gosingen.dyndns.tv/sura/1/programm/addmovie.php but note that
there is still a lot of mess to be cleant, the programming proably
looks disgusting to you. It is :)
您可能需要使用字符串(作为标识符)来
访问您构成元素:
var myelememnt = document.forms [''myformname'']。elements [''item []''];
以上是最多的访问表单元素的明确方式,但是:
var myelememnt = document.forms [''myformname''] [''item []''];
< br $> b $ b和
var myelememnt = document.myformname [''item []''];
应该有效也好。
Rob。
-
http://www.victim-prime.dsl.pipex.com/
完美作品,谢谢你们两个人:)
玩得愉快
Thorben
Works perfect, thanks to both of you :)
have a nice time
Thorben
这篇关于使用括号但不想拥有数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!