2012-04-08 10 views
0

私のPHPページの下部にいくつかの段落があります。ユーザーがドロップダウンからオプションを選択するたびに、次の関数が呼び出されて、そのオプションの値がURL変数に追加されます。現在のところ、このページは毎回トップに更新され、大きな問題です。通常は、次のようなものを使用します:onclick = "window.location = 'page.htm#bottom';"ページの一番下まで更新しますが、#bottomを追加すると下の関数は機能しなくなります。誰かがこの機能を調整するのを助けたり、機能が完了したときにページの一番下までリフレッシュする他のアイデアを教えてくれますか? self.location='add_products.php#bottom?fda=' + fdaURLの変数を含むjavascript関数を使用してページの一番下まで表示します

をしかし、これは行います:

function reload5(form){ 
if(document.getElementById('fda1').checked) { 
var fda = '1'; 
}else if(document.getElementById('fda0').checked) { 
    var fda = '0'; 
} 

var val=form.category.options[form.category.options.selectedIndex].value; 
var val2=form.subcat.options[form.subcat.options.selectedIndex].value; 
var val3=form.subcat1.options[form.subcat1.options.selectedIndex].value; 
var val4=form.subcat2.options[form.subcat2.options.selectedIndex].value; 
var comp1=form.mname.options[form.mname.options.selectedIndex].text; 
var itemnum=document.getElementById('item').value; 
var desc=document.getElementById('desc').value; 
var quan=document.getElementById('quan').value; 
var list=document.getElementById('list').value; 
var uom=form.uom.options[form.uom.options.selectedIndex].text; 
self.location='add_products.php#bottom?fda=' + fda + '&desc=' + desc + '&quan=' + quan + '&list=' + list + '&uom=' + uom + '&item=' + itemnum + '&cat=' + val + '&cat2=' + val2 + '&cat3=' + val3 + '&cat4=' + val4 + '&comp=' + comp1 ; 
} 

だから、これは動作しませんself.location='add_products.php?fda=' + fda

任意のアイデアどこ#bottomを入れて?

答えて

1

問題は、最後にクエリ文字列の後にハッシュを付ける必要があることです。記事のthisを参照してください。ページがすべてでリフレッシュさせないとAjaxで何かをしていない理由を私は理解していないことである

function reload5(form){ 
    var val=form.category.options[form.category.options.selectedIndex].value, 
     val2=form.subcat.options[form.subcat.options.selectedIndex].value, 
     val3=form.subcat1.options[form.subcat1.options.selectedIndex].value, 
     val4=form.subcat2.options[form.subcat2.options.selectedIndex].value, 
     comp1=form.mname.options[form.mname.options.selectedIndex].text, 
     itemnum=document.getElementById('item').value, 
     desc=document.getElementById('desc').value, 
     quan=document.getElementById('quan').value, 
     list=document.getElementById('list').value, 
     uom=form.uom.options[form.uom.options.selectedIndex].text, 
     fda; 

    if(document.getElementById('fda1').checked) { 
     fda = 1; 
    } else if(document.getElementById('fda0').checked) { 
     fda = 0; 
    } else { 
     fda = -1; 
    } 

    window.self.location.href = 'add_products.php?fda=' + fda + '&desc=' + desc + '&quan=' + quan + '&list=' + list + '&uom=' + uom + '&item=' + itemnum + '&cat=' + val + '&cat2=' + val2 + '&cat3=' + val3 + '&cat4=' + val4 + '&comp=' + comp1 + "#bottom"; 
} 

(私は、コードをクリーンアップ)...これを試してみてください。

+0

あなたの命を救う人。本当にありがとう。特にコードを整理するため。理由は私はまだアヤックスに行っていない、私は初心者ですが、私はこのページを書いた昨年、本当に初心者でした。私はおそらく今すぐ離陸することができただけでそれに慣れていない。再度、感謝します! –

関連する問題