Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why do I have to doubleclick on this link to see?

Status
Not open for further replies.
Oct 11, 2006
300
US
Hi,

Hi,

I have link on which I click and I am able to see all the products for the link. However when I refresh it, I need to click on the link 2 times and it displays and hides the products below the category link. Thereafter when I click on the link once, I get to show and hide the products.

What is it causing the 2 times click when I refresh the page?

My Javascript code is:
Code:
var xmlHttp

function showProducts(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}

var url="getProducts.asp"
url=url+"?ID="+str
//alert(url);
//url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged1
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged1()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//objID = 'UI_'+el;
		//document.getElementById(objID).innerHTML=xmlHttp.responseText
		document.getElementById("content_products").innerHTML=xmlHttp.responseText
	}
}

function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest) //Safari, Mozilla browers
{
	objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject) //IE browsers
{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}

function s_Hide(el){
	//alert("Showing Element: "+el);
	objID = 'UI_'+el;
	//alert(objID);
	obj = document.getElementById(objID).style;
	(obj.display == 'none')? obj.display = 'block' : obj.display = 'none';
}
 
you've shown exactly ZERO links. This question also seems to closely resemble another question you've recently asked.

how are we expected to help you with this? you've been here long enough, you should know by now what is considered proper posting etiquette.





*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Code above is the Javascript.

For the ASP part, it is below:

Code:
<a href="#" class="a_style" onclick="showProducts(<%=aCategory(0, iRows)%>);s_Hide('<%=aCategory(0, iRows)%>'); return false;"><%=aCategory(1, iRows)%></a>
            <ul id="UI_<%=aCategory(0, iRows)%>">         
            <div id="content_products">
            </div>
            </ul>
 
My HTML code looks like this:

Code:
<ul id="menu">
        <li>
            <input type="radio" checked name="prodid" id="Catid2" value="2">
            <a href="#" class="a_style" onclick="showProducts(2);s_Hide('2'); return false;">Condiments</a>
            <ul id="UI_2">
            
            <div id="content_products">
            </div>
            </ul>
        </li>
    </ul>

What I see is even with the Category "Beverage" expanded and the Products displayed, I still do not see the products in the Page source.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top