2011-12-21 4 views
-2

私はPHPを初めて使い、入力したデータをページに表示する方法を知る必要があります。私は明確にします。ページにテキストボックスがあり、ユーザーが何かを入力して送信をクリックすると、[ENTERED DATA HERE]と入力した空白のページが表示されます。私はテキストボックスにコードを入れて、正しいiframeを自動的に生成するようにしたいと思います。PHP - 入力したデータを表示するスクリプトを作成する

<iframe marginwidth="0" marginheight="0" src="http://jb-radio.com/movies/play.php?mu=[ENTERED DATA HERE]" frameborder="0" height="360" scrolling="no" width="640"></iframe>

私は、これはかなり簡単であるべきだと思う(私はそれがPHPで行われていると思います)このスクリプトに助けてください。

答えて

0

あなたは関係なしPHPでクライアントサイドのJavaScriptでこれを行うことができます。

<iframe id="the_iframe" style="display:none;" marginwidth="0" marginheight="0" src="" frameborder="0" height="360" scrolling="no" width="640"></iframe> 

<input id="the_input" type="text" /> 
<input id="the_button" type="button" value="Click me to change the iframe" /> 

<script type="text/javascript"> 
    document.getElementById('the_button').onclick = function() { 
    var theUrl = 'http://jb-radio.com/movies/play.php?mu='; 
    theUrl = theUrl + document.getElementById('the_input').value; 
    var theIframe = document.getElementById('the_iframe'); 
    theIframe.style.display = 'block'; 
    theIframe.src = theUrl; 
    }; 
</script> 

Try it out

+0

が良いですね! iframeを作成する代わりに、iframe CODEを出力する方法はありますか? – psl101

+0

うん、[this fiddle](http://jsfiddle.net/93yPT/2/)を参照してください – DaveRandom

+0

ありがとうございます!!!!!! – psl101

0

フォームを作成して作業することは、かなり基本的なトピックです。 Googleを使用してイントロのPHPレッスンを検索します。私が始めたとき、私はtizagを使いました。あなたの解決策は、$ _POSTまたは$ _GETのスーパーグローバルを使うことです(フォームメソッドに依存します)。ここで

0

はあなたがこれはあなたのページが使用していると仮定しているの$ IDに

<iframe marginwidth="0" marginheight="0" src="http://jb-radio.com/movies/play.php?mu=<?php $id ?>" frameborder="0" height="360" scrolling="no" width="640"></iframe> 

を含める必要がありますあなたのiframeのURLを設定するには、URL

url = "http://www.example.com/test.php?example_id=123" 

$id_1 = $_GET['example_id']; //equals 123 from the URL parameter 

からパラメータ値を取得する方法であります.htmlではなく.php拡張子。 .htmlページを使用するには、サーバーが.phpを解析できる必要があります。

関連する問題