Jump to content

How to modify this ajax suggestion


freak12345

Recommended Posts

please help me modify this script to make div scroll when using keyboard arrow up and down to selected the items.

 

var searchReq = open_xmlhttp();

function searchSuggest(CityName,StateName){

if(searchReq.readyState == 4 || searchReq.readyState == 0) {

var query = escape(document.getElementById('query_search').value);

var query_city = escape(CityName);

var query_state = escape(StateName);

nocache = Math.random();

searchReq.open('GET', 'index.php?<?php echo $visitorsid ?>=ajax_suggest_search&query='+query+'&city2='+query_city+'&state2='+query_state+'&nocache='+nocache);

searchReq.onreadystatechange = handleSearchSuggest;

searchReq.send(null);

}

}

function handleSearchSuggest(){

if(searchReq.readyState==4) {

var ssa = document.getElementById('sboxsuggest');

ssa.innerHTML = '';

var query = searchReq.responseText.split('\n');

if(query == '') {

document.getElementById('sboxassist').style.display = "none";

document.getElementById('sboxsuggest').style.display = "none";

document.getElementById('sboxscrollmain').style.display = "none";

document.getElementById('popupsmall_location').style.display = "none";

document.getElementById('popupsmall_login').style.display = "none";

} else {

document.getElementById('sboxscrollmain').style.display = "inline";

document.getElementById('sboxassist').style.display = "inline";

document.getElementById('sboxsuggest').style.display = "inline";

document.getElementById('popupsmall_location').style.display = "none";

document.getElementById('popupsmall_login').style.display = "none";

}

       

for(i=0; i < query.length-1; i++) {

I want to modify this part to be able to scroll and up down using arrow up and down to select the items.

                              var suggesta = '<div style="border: 3px solid gray" onmouseover="suggestOver(this);"';

suggesta += 'onmouseout="suggestOut(this);"';

suggesta += 'onclick="setSearch(this.innerHTML);"';

suggesta += 'class="sboxsuggest">'+query+'</div>';

ssa.innerHTML += suggesta;

}

}

function suggestOver(div_value){

div_value.className = 'sboxsuggestlinkover';

}

function suggestOut(div_value){

div_value.className = 'sboxsuggestlink';

}

function setSearch(value){

document.getElementById('query_search').value = value;

document.getElementById('sboxassist').style.display = "none";

document.getElementById('sboxsuggest').style.display = "none";

document.getElementById('sboxscrollmain').style.display = "none";

document.getElementById('popupsmall_location').style.display = "none";

document.getElementById('popupsmall_login').style.display = "none";

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.