2011-08-17 3 views
0

フォームが既存のテキストフィールドに投稿されている場合は、送信ボタンの値が必要です。以下はコードです。PHPでフォームが投稿されているときにテキストフィールドにsubmitの値を取得

私は試してみましたが、新しいテキストフィールドを作成しています。

<?php 
$var1 = $_POST['hello']; 
//below here i am trying out something but not getting in exiting textfield. 
//i need the value of submit button ie some value in exiting textfield ie text1 
echo "<input type='text' name='text1' value='$var1'>"; 

?> 

<form method="post"> 
<input type="submit" name="hello" value="some value"> 
<input type="text" name="text1" value="dskfjls"> 
</form> 

答えて

0

echoが行っているので、新しいテキストフィールドが作成されます。

だけで行うように変更します。

<?php 
$submitbutton = $_POST['hello']; 
$textbox = $_POST['text1']; 
//below here i am trying out something but not getting in exiting textfield. 
//i need the value of submit button ie some value in exiting textfield ie text1 
echo $submitbutton; 
echo $textbox; 

?> 

<form method="post"> 
<input type="submit" name="hello" value="some value"> 
<input type="text" name="text1" value="dskfjls"> 
</form> 

編集この

使用コメントに返信で:

<form method="post"> 
<input type="submit" name="hello" value="some value"> 
<input type="text" name="text1" value="<?php (isset($_POST['hello'])?$_POST['hello']:null); ?>"> 
</form> 
+0

を私はsubmitボタンの値がテキストフィールド – uzair

+0

上に表示させたいです@モハメッド、私の返信を参照してください – Prisoner

+0

上記のコードは動作していないと私はコンセプトを得た値を表示してみても、これを試してみました。 "

' – uzair

関連する問題