value
атрибут checkbox
- то, чем Вы устанавливаете:
<input type='checkbox' name='test' value='1'>
Поэтому, когда кто-то устанавливает тот флажок, сервер получает переменную, названную test
с value
из 1
- на что Вы хотите проверить, не value
из него (который никогда не будет изменяться, проверяется ли это или не), но checked
состояние флажка.
Так, если Вы заменяете этот код:
if (arrChecks[i].value == "on")
{
arrChecks[i].checked = 1;
} else {
arrChecks[i].checked = 0;
}
С этим:
arrChecks[i].checked = !arrChecks[i].checked;
Это должно работать. Необходимо использовать true
и false
вместо [1 112] и 1
для этого.
Нет.
Другого способа сделать в принципе нет. Представленные здесь предложения работают, но кажутся более сложными, чем прямое решение, и менее ясными.
How about this:
1> atom_to_list('He said "hello" and then she answered "hi".').
"He said \"hello\" and then she answered \"hi\"."
You can define a macro to abbreviate atom_to_list for improved readability.
Прежде всего я хотел бы сказать, что использование таких строковых кавычек - неплохая идея для будущих версий Erlang. Но я не задерживаю дыхание, чтобы оно пришло. Python хорошо использует их в качестве "неизмененных" многострочных строк документов.
Если бы меня достаточно раздражала необходимость избегать кавычек и обратных косых черт, я бы подумал о разработке макроса преобразования в моем редакторе, чтобы сделать это за меня в текущий выделенный текст. Или, может быть, просто реализовать его с помощью регулярного выражения в sed, чтобы вырезать и вставить. :)
$ echo 'Testing a "robust" way to \quote\ things.' | sed -e 's/[\\"]/\\&/g'
Testing a \"robust\" way to \\quote\\ things.
I believe your best choice is to put your multi-line doublequote-full string into a separate file, and then read it with the new file:read_line, concatenating the lines at boot-up of your app.
Or if you want to have an über-mess, you can combine this with parse-transforms. You can place your string(s) into the source code, commented out and when the parse transform is invoked, you open up the source file, read out the text from the comments, concatenate and replace. Example:
...
Len = erlang:length("MY_FAKE_STRING_13"),
%% This is my "double-qouted"
%% "multi-line" string;
%% you know what I mean ;)
...
In your parse transform you look for strings starting with MY_FAKE_STRING. When you find one, you open up your module's source code, and read line's until you reach the very same string. Then read your source line-by-line until comments are coming, and concatenate them. Reaching the first empty (or non-comment) line, you have your string, which you can return instead of the fake string.