![](http://oshiete.xgoo.jp/images/v2/pc/qa/question_title.png?5a7ff87)
雑誌やネットを調べ、ラジオボタンで入力項目の可・不可を切り替える
JavaScriptを見つけたのですが、思うように動作しません。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitio …
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />
<title>Sample</title>
<script type="text/javascript">
<!--
function radioChange() {
if(document.form1.radioSelect[0].checked == true) {
document.form1.04text.disabled = false;
document.form1.04text.style.backgroundColor='#FFFFFF';
document.form1.05text.disabled = false;
document.form1.05text.style.backgroundColor='#FFFFFF';
document.form1.06text.disabled = false;
document.form1.06text.style.backgroundColor='#FFFFFF';
document.form1.07text.disabled = true;
document.form1.07text.style.backgroundColor='#D4D0C8';
document.form1.08text.disabled = true;
document.form1.08text.style.backgroundColor='#D4D0C8';
document.form1.09text.disabled = true;
document.form1.09text.style.backgroundColor='#D4D0C8';
} else if(document.form1.radioSelect[1].checked == true) {
document.form1.04text.disabled = true;
document.form1.04text.style.backgroundColor='#D4D0C8';
document.form1.05text.disabled = true;
document.form1.05text.style.backgroundColor='#D4D0C8';
document.form1.06text.disabled = true;
document.form1.06text.style.backgroundColor='#D4D0C8';
document.form1.07text.disabled = false;
document.form1.07text.style.backgroundColor='#FFFFFF';
document.form1.08text.disabled = false;
document.form1.08text.style.backgroundColor='#FFFFFF';
document.form1.09text.disabled = false;
document.form1.09text.style.backgroundColor='#FFFFFF';
} else {
document.form1.04text.disabled = true;
document.form1.04text.style.backgroundColor='#D4D0C8';
document.form1.05text.disabled = true;
document.form1.05text.style.backgroundColor='#D4D0C8';
document.form1.06text.disabled = true;
document.form1.06text.style.backgroundColor='#D4D0C8';
document.form1.07text.disabled = true;
document.form1.07text.style.backgroundColor='#D4D0C8';
document.form1.08text.disabled = true;
document.form1.08text.style.backgroundColor='#D4D0C8';
document.form1.09text.disabled = true;
document.form1.09text.style.backgroundColor='#D4D0C8';
}
}
//-->
</script>
</head>
<body onload="radioChange()">
<form action="" method="post" name="form1">
<table>
<tr>
<td>
<input name="radioSelect" type="radio" onclick="radioChange()" value="1" />
国内旅行
<input name="radioSelect" type="radio" onclick="radioChange()" value="0" />
海外旅行</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>
国内編:<br />
希望地
<input type="text" name="04text" />
<br />
希望日:
<input type="text" name="05text" />
<br />
乗り物:
<input type="text" name="06text" />
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>海外編:<br />
希望地
<input type="text" name="07text" />
<br />
希望日:
<input type="text" name="08text" />
<br />
乗り物:
<input type="text" name="09text" />
</td>
</tr>
</table>
</form>
</body>
</html>
テキストボックスの「name」を、英字から始めれば解決するのですが
事情があり、nameを数字で始める必要があります。
この解決方法を教えていただけませんでしょうか。
よろしくお願いいたします。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- CGI perlで書いたcgiでsqliteの使い方を教えてください 2 2023/05/08 21:29
- PHP PHPのエラーの解消法について教えて下さい。 1 2023/02/06 10:48
- JavaScript EasyUIのSubGrid(jquery)におけるObjectに入れた連想配列について 1 2022/05/02 11:21
- PHP 入力した部分を表示させたまま(保持)するにはどうすれば良いでしょうか? 1 2023/01/25 11:14
- JavaScript 画像の表示位置 3 2022/12/23 08:25
- HTML・CSS 私の能力からして間違っていないような気がします。 4 2022/09/30 13:24
- JavaScript GoogleChart 階層ごとのブロックの長さを個別に設定したい 1 2022/07/06 14:27
- HTML・CSS CSS のみのタブ切り替えについて 1 2023/01/11 16:47
- HTML・CSS <!DOCTYPE html> <html> <head> <meta charset="utf-8 2 2023/01/05 01:04
- JavaScript javascript作成してます。ラジオボタンで判定するコードを書いてます。 1 2023/07/18 11:03
関連するカテゴリからQ&Aを探す
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
ページ間で変数を保持したい
-
テキストエリアに履歴を残したい
-
TextBoxに半角数字以外を入れた...
-
GetElementByIdがうまく取得で...
-
テキストボックスのフォーカス移動
-
大文字か小文字かを判断する方法
-
IE上のカーソル位置に文字列を...
-
Request.Form(key)の中身をクリ...
-
依頼 html・javascriptどちらで...
-
マイナスなら赤字で表示したい...
-
tabindexの取得
-
ラジオボタンで入力項目の可・...
-
input要素のtype属性を変えたい
-
テキストボックスに入力した色...
-
HTMLとJavaScriptで作った表示...
-
perl cgi文字化け解消方法と[1...
-
jQueryのdatepickerの日付が選...
-
入れ替えた画像をクリッカブル...
-
フォームの内容でリンク先URLの...
-
[JavaScript]ボタンを押下する...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
TextBoxに半角数字以外を入れた...
-
HTMLファイル同士での値渡し
-
ページ間で変数を保持したい
-
マイナスなら赤字で表示したい...
-
プルダウンで選択された値を別...
-
HTMLとJavaScriptで作った表示...
-
テキストエリアに履歴を残したい
-
フォームの内容でリンク先URLの...
-
tabindexの取得
-
テキストボックスに入力した色...
-
VBscriptの配列変数をJavascrip...
-
GetElementByIdがうまく取得で...
-
javascriptのちょっとした動作...
-
どちらかひとつのテキストボッ...
-
VBScriptでpingを実行(ブラウザ...
-
大文字か小文字かを判断する方法
-
jQueryのdatepickerの日付が選...
-
フォーカスが外れた時の入力チ...
-
JavaScriptからphp関数の呼び出し
-
フォーカス設定について教えて...
おすすめ情報