473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Strange problem in JS code

hi all;
i'm doing here an autocompletion module in the envirnment
(XFORMS/XHTML).
this is the code:

<?xml version="1.0" encoding="UTF-8"?>
<xhtml:html xmlns="http://xforms.websynapsis.com"
xmlns:books="http://books.websynapsis.com"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xhtml:head>

<xf:model id="myModel">
<xf:instance xmlns="" id="myInstance">
<instanceData selected="">
<itemlist>
</itemlist>
</instanceData>
</xf:instance>

<xf:bind model="myModel"
nodeset="instance('myInstance')/itemlist/item[position()&lt;6]"
id="__items" />
</xf:model>

<xhtml:script type="text/javascript">
<![CDATA[
function affiche1()
{
var model = document.getElementById("myModel");
var instanceDoc = model.getInstanceDocument("myInstance");
var sel = document.getElementById("__itemList");
sel.addEventListener("keyup",g,true);
}
function g()
{
alert("ouf")
changeModel1(1)
}

function changeModel1(count1)
{
vider()
var found=new Array()
var model = document.getElementById("myModel");
if(model != null)
{
var inst = model.getInstanceDocument("myInstance");
if(inst != null)
{
var insertPoint = inst.getElementsByTagName("itemlist").item(0);
var itemCount = insertPoint.getElementsByTagName("item").length;
var k=0;
if(k<count1)
{
var element1 = inst.evaluate('//instanceData',inst,
null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNo deValue;
var element =
inst.evaluate('//instanceData/@selected',inst, null,
XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNo deValue;
found=search(element.textContent)
vider()
for(x=0;x<found.length;x++)
{
var item = document.createElementNS("", "item");
item.appendChild(document.createTextNode(found[x]));
insertPoint.appendChild(item);
k=k+1;
}
} }

rafraichir(model,element)

}
}
function search(value)
{
//alert("entrée")
var tab=remplir()
var y=0
var tab2=new Array()
for(x=0;x<tab.length;x++)
{
if(value.length>0 && tab[x].indexOf(value)>-1 )
{
tab2[y]=tab[x]
y=y+1
}
}
return(tab2)
}
function rafraichir(model,element)
{
model.rebuild();
model.refresh();

}

function remplir()
{
var tab=new Array()
tab[0]="bbcd"
tab[1]="abbc"
tab[2]="bb"
tab[3]="a"
return tab

}
function vider()
{
var model = document.getElementById("myModel");
var inst = model.getInstanceDocument("myInstance");
var insertPoint = inst.getElementsByTagName("itemlist").item(0);
var items = insertPoint.getElementsByTagName("item");
for( i=0; i<items.length; i++)
{
insertPoint.removeChild(items[i]);
}
}
]]>

</xhtml:script>
<xhtml:style type="text/css">
@namespace xf url("http://www.w3.org/2002/xforms");
xf|select1 div { width: 100px; }

</xhtml:style>
</xhtml:head>

<xhtml:body>

<xhtml:table border="0" cellspacing="0" cellpadding="0">
<xhtml:tr>
<xhtml:td valign="top">
<xf:select1 id="__itemList" ref="@selected" selection="open"
appearance="minimal">
<xf:itemset model="myModel"
nodeset="instance('myInstance')/itemlist/item" id="__items">
<xf:label ref="." />
<xf:value ref="." />
</xf:itemset>
</xf:select1>
<xhtml:span style="font-weight:bold">Selected item: </xhtml:span>
<xf:output model="myModel" ref="@selected" />

</xhtml:td>
<xhtml:td width="20px">
</xhtml:td>
</xhtml:tr>
</xhtml:table>
<xhtml:br />
<xhtml:input type="button" value="Add Listener" onclick="affiche1();"/>
</xhtml:body>
</xhtml:html>
the strange thing is that if i remove the alert("ouf") nothing work.
can you help me to find the pb.
Thanks

Oct 5 '06 #1
5 1360
sniper wrote on 05 okt 2006 in comp.lang.javascript:
the strange thing is that if i remove the alert("ouf") nothing work.
can you help me to find the pb.
[pb's are not part of the usenet vocabulary]

If things do not work when removing
an alert('')
in general it is a timing issue.

A result is not ready yet.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 5 '06 #2

Evertjan. wrote:
If things do not work when removing
an alert('')
in general it is a timing issue.

A result is not ready yet.
so ther's no solution ??

Oct 5 '06 #3
sniper wrote on 05 okt 2006 in comp.lang.javascript:
Evertjan. wrote:
>If things do not work when removing
an alert('')
in general it is a timing issue.

A result is not ready yet.
so ther's no solution ??
Did I say that?

Usenet is not a payed helpdesk,
I was suggesting where to look for the bug.

Perhaps, if you do not follow my lead,
someone else is kind enough to plough through your long code.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 5 '06 #4

Evertjan. wrote:
Usenet is not a payed helpdesk,
I was suggesting where to look for the bug.

Perhaps, if you do not follow my lead,
someone else is kind enough to plough through your long code.
thanks for your precious help.

Oct 5 '06 #5
sniper wrote on 05 okt 2006 in comp.lang.javascript:
Evertjan. wrote:
>Usenet is not a payed helpdesk,
I was suggesting where to look for the bug.

Perhaps, if you do not follow my lead,
someone else is kind enough to plough through your long code.

thanks for your precious help.
You are welcome.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: jamesbeswick | last post by:
I've been using Access since version 97 and I've migrated to 2003. I've noticed a substantial number of strange ActiveX/OLE and code corruption problems when writing databases. The only solution...
1
by: Default | last post by:
Hi, I am new to C#, that is why I am not sure what kind of problem it is: Is VS files corrupted , or something else. that is the problems description: I am working on a small database project. I am...
1
by: Fabrizio | last post by:
On a web page i found a very strange html code (see at the en of this message) to set the type of the characters (like bold, italic, etc.) and I have 2 question 1) How interpreter this code ?...
3
by: Tina | last post by:
I have been developing in C# for a few months now and thought I knew the language but recently I came accross the code pasted below. What is <Theme>? I don't understand the use of <other than...
0
by: jimmyjoe | last post by:
xp pro sp2 vs 2005 I'm getting this bizarre error: Server Error in '/CS' Application "System.Web.Services.Protocols.SoapException: Server was unable to process request....
4
by: dhaval.bhanu | last post by:
Hi .. Well I have a strange code here which i am not usre have a clear understanding. I have compiled it on turbo C++3.0 compiler and Devc++ compiler .. here is the code ..
4
by: tamara omar | last post by:
i want to know what happens when we run this code below? void main(){ long *p=new long; while(p) p=new long; cout<<*p<<endl; }
1
by: | last post by:
I have signed up to a dotnet hosting account and I have a dotnet app called CommunityServer, which allows me to setup my own news forums. The path of one of my forums (the third one) is ...
4
by: Dr J R Stockton | last post by:
Should <http://www.wikicodia.com/wiki/CSS_Custom_Cursors work? -- (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME. Web <URL:http://www.merlyn.demon.co.uk/-...
5
by: mingle | last post by:
Hi, I have a .pm file, which was placed within my site when it got hacked, i've never used perl before, but after some googling I thought I'd ask the pros at these forums. Heres the code which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.