2014-11-02 92 views
0

我想問我怎樣才能使用我自己的值進度欄,這將顯示多少信用度,直到您預設的最大預算? 輸入類型是文本,看看是否有值。進度條有一些進展,但那是因爲我手動輸入了兩個值。 http://postimg.org/image/fbjnrvvgn/jQuery的進度欄與PHP變量

CODE:

<input type="text" id="max_budget" value="<?php include_once 'budget_calc.php'; echo $max_budget_echo; ?>"> 
<input type="text" id="calculated_budget" value="<?php include_once 'budget_calc.php'; echo $total ?>"> 
<script> 
$(function() { 
$("#progressbar").progressbar({ 
    max: 1000, 
    value: 100 
}); 
}); 
</script> 
<div id="progressbar"></div> 

我想有從用戶設定最大最大的數據庫和價值$計算的總= $ I-$ O, 這樣的:

<script> 
$(function() { 
$("#progressbar").progressbar({ 
max: $('#max_budget').val(), 
    value: $('calculated_budget').val() 
}); 
}); 
</script> 

我也累了這個:

<script> 
var max_budget=<?php include_once 'budget_calc.php'; echo $max_budget_echo; ?> 
var calculated_budget=<?php include_once 'budget_calc.php'; echo $total; ?> 
$(function() { 
$("#progressbar").progressbar({ 
max: max_budget, 
value: calculated_budget 
}); 
}); 
</script> 

但nothig作品:( 我該如何解決這個問題? 謝謝您的時間(:

回答

0

你爲什麼不只是 '回聲' 他們,你需要他們

<?php include_once 'budget_calc.php'; ?> 
<script> 
$(function() { 
$("#progressbar").progressbar({ 
max: <?php echo $max_budget_echo; ?>, 
value: <?php echo $total; ?> 
}); 
}); 
</script> 

如果無法正常工作,請檢查您的HTML/JS-代碼

+0

感謝您的幫助。有效, – nyler 2014-11-03 15:39:54

0

喜?。你包括將在PHP文件的頂部,就像這

<?php include_once 'budget_calc.php'; ?> 

<input type="text" id="max_budget" value="<?php echo $max_budget_echo; ?>"> 
<input type="text" id="calculated_budget" value="<?php echo $total; ?>"> 
<div id="progressbar"></div> 

<script> 
$(function() { 
$("#progressbar").progressbar({ 
    max: $('#max_budget').val(), 
    value: $('#calculated_budget').val() 
}); 
}); 
</script> 

這會所做的工作。第二個解決方案可能是。

<?php include_once 'budget_calc.php'; ?> 
<script> 
var max_budget = "<?php echo $max_budget_echo; ?>"; 
var calculated_budget = "<?php echo $total; ?>"; 
$(function() { 
$("#progressbar").progressbar({ 
max: max_budget, 
value: calculated_budget 
}); 
}); 
</script> 

確保您在文件budget_calc.php中有$ max_budget_echo和$ total。希望這將有助於解決問題。