0

このコードを使用して、インクルード パスを JavaScript で変更しています。

$('#actionLink').attr('href', $('#actionLink').attr('href')  + '?page=welcome');


 switch($_GET['page'])) {
     case 'welcome':
         include 'section/welcome.html';
         break;
     case 'nda':
         include 'section/nda.html';
         break;
 }

しかし、submitbutton を使用してこれを行うにはどうすればよいでしょうか。

4

4 に答える 4

1

ボタンにページのURL名を表示するには:

<form method="get" action="<this page's address>">
    <input type="submit" name="page" value="page1" />
    <input type="submit" name="page" value="page2" />
</form>

または、そこに他のテキストを表示するには:

<form method="get" action="<this page's address>">
    <input type="submit" name="page" value="Page 1 button text" onclick="this.value='page1'" />
    <input type="submit" name="page" value="Page 2 button text" onclick="this.value='page2'" />
</form>

または最後に、隠しフィールドと jQuery を使用:

<form method="get" action="<this page's address>">
    <input type="submit" value="Page 1 button text" onclick="$('#hidden').val('page1')" />
    <input type="submit" value="Page 2 button text" onclick="$('#hidden').val('page2')" />
    <input type="hidden" name="page" id="hidden" />
</form>
于 2013-06-24T11:57:10.897 に答える
0

これを試すことができます:

<form method="POST" action="yourpage.php">
     ....
     <input type="hidden" name="page" id="page" value="welcome">
     <input type="submit" value="submit" />
 </form>

// $_REQUEST works for both $_GET and $_POST
switch($_REQUEST['page'])) {
     case 'welcome':
         include 'section/welcome.html';
         break;
     case 'nda':
         include 'section/nda.html';
         break;
 }

これが何かの助けになることを願っています。

于 2013-06-24T11:57:39.643 に答える
0
$('button').onclick(function() {
$(location).attr('href', 'www.example.com'); //redirect to www.example.com
});
于 2013-06-24T11:48:14.843 に答える
0

HTMLで行うだけです。

 <form method="GET" action="?page=whatever">
     <input type="submit" value="Click Me!" />
 </form>
于 2013-06-24T11:48:23.730 に答える