▼フォーム要素をクリックしてください。フォーム要素の選択値をクエリー文字列にして表示します。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="ja" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="imagetoolbar" content="no" /> <title>非同期通信:その他:selialize()の使用例 | jQuery</title> <link rel="stylesheet" type="text/css" href="/content/lib/global.css" /> <!-- JS --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(function(){ function showValues(){ var str=$("form").serialize(); $("#res").html("<strong>クエリー文字列:</strong>"+str); } $(":checkbox, :radio").click(showValues); $("select").change(showValues); showValues(); }); </script> <style type="text/css"> form { margin:5px; } #res { color:red; } </style> <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head> <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1> <h3 class='h'>実行結果</h3> <div id="wrap"> <h1>非同期通信:その他:selialize()の使用例 | jQuery</h1> <p>▼フォーム要素をクリックしてください。フォーム要素の選択値をクエリー文字列にして表示します。</p> <!-- CODE --> <form> <p> <select name="single"> <option>Single</option> <option>Single2</option> </select> </p> <p> <select name="multiple" multiple="multiple"> <option selected="selected">Multiple</option> <option>Multiple2</option> <option selected="selected">Multiple3</option> </select> </p> <p> <label for="ch1"><input type="checkbox" name="ch1" value="check1" id="ch1" />check1</label> <label for="ch2"><input type="checkbox" name="ch2" value="check2" checked="checked" id="ch2" />check2</label> <label for="r1"><input type="radio" name="radio" value="radio1" checked="checked" id="r1" />radio1</label> <label for="r2"><input type="radio" name="radio" value="radio2" id="r2" />radio2</label> </p> </form> <p id="res"></p> <!-- CODE / --> </div> </body> </html>