2012-10-05 49 views
0

嘿我試圖得到這個工作在這裏:建築img標籤jQuery的PHP字符串

<? 
echo ('<script type="text/javascript"> 
$(\'#fileupload\').fileupload({ 
}).bind(\'fileuploaddone\', function (e, data) { 
    jQuery("#shadow").attr("src", "bannerImg/slider/\'' . 
    ' + jQuery(\"#slideNum\").val(); + '); 
    echo ('\'.jpg"); 
    jQuery("#theText").html("New Slider Image:");') ?> 

它上傳調用此腳本的圖像後,我需要它來查看選擇了什麼樣的價值在選擇框中。然而,所有我得到這個:

所以自然也不會顯示圖像的工作。我該如何修改這個以便讓它按我需要的方式工作?

回答

0
<script type="text/javascript"> 
    $('#fileupload').fileupload({ 
    }).bind('fileuploaddone', function (e, data) { 
    jQuery("#shadow").attr("src", "bannerImg/slider/" + jQuery("#slideNum").val() + '.jpg'); 
    jQuery("#theText").html("New Slider Image:"); 

代替:

<? 
echo ('<script type="text/javascript"> 
$(\'#fileupload\').fileupload({ 
}).bind(\'fileuploaddone\', function (e, data) { 
    jQuery("#shadow").attr("src", "bannerImg/slider/\'' . 
    ' + jQuery(\"#slideNum\").val(); + '); 
    echo ('\'.jpg"); 
    jQuery("#theText").html("New Slider Image:");') ?> 
1
<?php if($_POST['submit']){ ?> 

     <script> 
     //your script here 
     </script> 

<?php } ?> 

遵循這一理念,而不是附和你的腳本不如把你的腳本2 PHP裏面封閉的標籤,如上面的代碼..

+0

好吧我做到了,我得到了它的工作。感謝克林特的提示。 – StealthRT

+0

您的歡迎..也呼應一些HTML和其他腳本比PHP更容易,如果正在做這樣的事情,尤其是標籤用引號「」或「'.. :) –