/    Sign up×
Community /Pin to ProfileBookmark

Joke make problem

For some reason the joke maker is not working. With this, they can do 4 things 1. make a joke 2. make an answer for their joke 3. look at other’s jokes 4. check their answers. Nothing works.

There are 44 people, plus visitors on the site, each with a number form 5999 – 6043(plus 5998, which is a visitor one).

I have a two javascripts(one for the xml load doc), an XML document, and of course, the web page html document.

Javascript one:

[CODE]function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xhttp.open(“GET”,dname,false);
xhttp.send();
return xhttp.responseXML;
}[/CODE]

Javascrirpt two:

[CODE]function answers()
{var pn=prompt(“Which person number?”);
var jn=prompt(“Which joke number?”);
if (pn=<6043 && pn=>5998 && jn=>5998 && jn=<6043) {
xmlDoc=loadXMLDoc(“jokesxml.xml”);
var av=xmlDoc.getElementsByTagName(“jokesans”+pn)[0].childNodes[0].nodeValue;
var asv=av.getElementsByTagName(“j”+jn)[0].childNodes[0].nodeValue;
var q=prompt(“What do you think the answer is?”,”I don’t know”);
if (q==asv)
{ar();}
else
{aw();}}
else {var alert(“The person, or joke number is not a valid number”);}
function ar()
{var ar=alert(“Correct!”);}
function aw()
{
var aw=alert(“No, it was “+asv);}}
function submit(form)
{xmlDoc=loadXMLDoc(“jokesxml.xml”);
var jnum=form.jnum.value;
var pnumber=form.pnumber.value;
var joke=form.joke.value;
var an=form.an.value;
new=xmlDoc.createElement(“j”+jnum);
newj=xmlDoc.createTextNode(joke);
x=xmlDoc.getElementsByTagName(“jokesques”+pnumber)[0];
new.appendChild(newj);
x.appendChild(new);}
function show_joke(n)
{xmlDoc=loadXMLDoc(“jokesxml.xml”);
var num=xmlDoc.getElementsByTagName(‘jokesques’+n)[0].childNodes[0].nodeValue;
var num1=num.getElementsByTagName(‘j1’)[0].childNodes[0].nodeValue;
var num2=num.getElementsByTagName(‘j2’)[0].childNodes[0].nodeValue;
var num3=num.getElementsByTagName(‘j3’)[0].childNodes[0].nodeValue;
var num4=num.getElementsByTagName(‘j4’)[0].childNodes[0].nodeValue;
var num5=num.getElementsByTagName(‘j5’)[0].childNodes[0].nodeValue;
var num6=num.getElementsByTagName(‘j6’)[0].childNodes[0].nodeValue;
var num7=num.getElementsByTagName(‘j7’)[0].childNodes[0].nodeValue;
var num8=num.getElementsByTagName(‘j8’)[0].childNodes[0].nodeValue;
var num9=num.getElementsByTagName(‘j9’)[0].childNodes[0].nodeValue;
var num10=num.getElementsByTagName(‘j10’)[0].childNodes[0].nodeValue;
document.getElementById(‘1d’).innerHTML=num1;
document.getElementById(‘2d’).innerHTML=num2;
document.getElementById(‘3d’).innerHTML=num3;
document.getElementById(‘4d’).innerHTML=num4;
document.getElementById(‘5d’).innerHTML=num5;
document.getElementById(‘6d’).innerHTML=num6;
document.getElementById(‘7d’).innerHTML=num7;
document.getElementById(‘8d’).innerHTML=num8;
document.getElementById(‘9d’).innerHTML=num9;
document.getElementById(’10d’).innerHTML=num10;
}[/CODE]

XML(I had to shorten it, because I had too many characters in the post. Please guess the rest):

[CODE]<jokes>

<othersj>

<jokesans5998></jokesans5998>

<jokesques5998>
</jokesques5998>

<jokesques5999></jokesques5999><jokesans5999>
</jokesans5999>

</othersj><stj>

<jokesques6000></jokesques6000><jokesans6000>
</jokesans6000>…

[/CODE]

The HTML:

[code=html]<input onclick=”answers()” value=”Get answers” type=”button”><br>
<input onclick=”show_joke(‘5998’)” value=”Show other’s(5998) jokes” type=”button”>
<input onclick=”show_joke(‘5999’)” value=”Show other(5999) jokes” type=”button”><input onclick=”show_joke(‘6000’)” value=”Show rocket’s(6000) jokes” type=”button”><input onclick=”show_joke(‘6001’)” value=”Show other(6001) jokes” type=”button”><input onclick=”show_joke(‘6002’)” value=”Show other(6002) jokes” type=”button”><input onclick=”show_joke(‘6003’)” value=”Show other(6003) jokes” type=”button”><input onclick=”show_joke(‘6004’)” value=”Show other(6004) jokes” type=”button”><input onclick=”show_joke(‘6005’)” value=”Show other(6005) jokes” type=”button”><input onclick=”show_joke(‘6006’)” value=”Show other(6006) jokes” type=”button”><input onclick=”show_joke(‘6007’)” value=”Show other(6007) jokes” type=”button”><input onclick=”show_joke(‘6008’)” value=”Show other(6008) jokes” type=”button”><input onclick=”show_joke(‘6009’)” value=”Show other(6009) jokes” type=”button”><input onclick=”show_joke(‘6010’)” value=”Show other(6010) jokes” type=”button”><input onclick=”show_joke(‘6011’)” value=”Show other(6011) jokes” type=”button”><input onclick=”show_joke(‘6012’)” value=”Show other(6012) jokes” type=”button”><input onclick=”show_joke(‘6013’)” value=”Show other(6013) jokes” type=”button”><input onclick=”show_joke(‘6014’)” value=”Show other(6014) jokes” type=”button”>
<input onclick=”show_joke(‘6015’)” value=”Show other(6015) jokes” type=”button”><input onclick=”show_joke(‘6016’)” value=”Show other(6016) jokes” type=”button”><input onclick=”show_joke(‘6017’)” value=”Show other(6017) jokes” type=”button”><input onclick=”show_joke(‘6018’)” value=”Show other(6018) jokes” type=”button”><input onclick=”show_joke(‘6019’)” value=”Show other(6019) jokes” type=”button”><input onclick=”show_joke(‘6020’)” value=”Show other(6020) jokes” type=”button”><input onclick=”show_joke(‘6021’)” value=”Show other(6021) jokes” type=”button”><input onclick=”show_joke(‘6022’)” value=”Show other(6022) jokes” type=”button”><input onclick=”show_joke(‘6023’)” value=”Show Tnjnt(6023) jokes” type=”button”><input onclick=”show_joke(‘6024’)” value=”Show other(6024) jokes” type=”button”><input onclick=”show_joke(‘6025’)” value=”Show other(6025) jokes” type=”button”><input onclick=”show_joke(‘6026’)” value=”Show other(6026) jokes” type=”button”><input onclick=”show_joke(‘6027’)” value=”Show other(6027) jokes” type=”button”><input onclick=”show_joke(‘6028’)” value=”Show other(6028) jokes” type=”button”><input onclick=”show_joke(‘6029’)” value=”Show other(6029) jokes” type=”button”><input onclick=”show_joke(‘6030’)” value=”Show other(6030) jokes” type=”button”>
<input onclick=”show_joke(‘6031’)” value=”Show other(6031) jokes” type=”button”><input onclick=”show_joke(‘6032’)” value=”Show other(6032) jokes” type=”button”><input onclick=”show_joke(‘6033’)” value=”Show other(6033) jokes” type=”button”><input onclick=”show_joke(‘6034’)” value=”Show other(6034) jokes” type=”button”><input onclick=”show_joke(‘6035’)” value=”Show other(6035) jokes” type=”button”><input onclick=”show_joke(‘6036’)” value=”Show other(6036) jokes” type=”button”><input onclick=”show_joke(‘6037’)” value=”Show other(6037) jokes” type=”button”><input onclick=”show_joke(‘6038’)” value=”Show other(6038) jokes” type=”button”><input onclick=”show_joke(‘6039’)” value=”Show other(6039) jokes” type=”button”><input onclick=”show_joke(‘6040’)” value=”Show other(6040) jokes” type=”button”><input onclick=”show_joke(‘6041’)” value=”Show other(6041) jokes” type=”button”><input onclick=”show_joke(‘6042’)” value=”Show other(6042) jokes” type=”button”><input onclick=”show_joke(‘6043’)” value=”Show other(6043) jokes” type=”button”><br>
<input onclick=”answers()” value=”Get answers” type=”button”><br>
1.<div id=”1d”></div>2.<div id=”2d”></div>3.<div id=”3d”></div>4.<div id=”4d”></div>

5.<div id=”5d”></div>6.<div id=”6d”></div>

7.<div id=”7d”></div>8.<div id=”8d”></div>9.<div id=”9d”></div>10.<div id=”10d”></div><br>
<form name=”myform” action=”” method=”get”>
Your #(visitors use 5998):<br>
<input name=”number” type=”text”> <br>
Joke number(if you haven’t done any, it’s 1, if you’ve done 1, it’s 2
ect.):<br>
<input name=”jnum” type=”text”><br>
Your joke:<br>
<input name=”joke” type=”text”><br>
Answer(if you have one):<br>
<input name=”an” type=”text”><br>
<input name=”button1″ value=”Make your joke” onclick=”submit(this.form)” type=”button”></form> [/code]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJun 07.2011 — How about a link to the problem so we can see it in action and view the errors first hand?
Copy linkTweet thisAlerts:
@JMRKERJun 08.2011 — Based upon your test page, I cannot test out the following because I don't have access to your joke files, external JS files, etc.

I modified it to be more compressed. Note, ID values cannot start with a number, so I changed id="1d" to id="d1d", etc.

I don't have any way to check to see if that makes it work or not.
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;!-- From: http://www.webdeveloper.com/forum/showthread.php?t=247323 --&gt;
&lt;!-- following scripts not supplied at this time
&lt;script type="text/javascript" src="loadxmldoc.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="makeajokeccs.js"&gt;&lt;/script&gt;
--&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input onclick="answers()" value="Get answers" type="button"&gt;&lt;br&gt;
&lt;br&gt;
&lt;input onclick="show_joke('5998')" value="Show other's(5998) jokes" type="button"&gt;
&lt;input onclick="show_joke('5999')" value="Show other(5999) jokes" type="button"&gt;
&lt;input onclick="show_joke('6000')" value="Show rocket's(6000) jokes" type="button"&gt;
&lt;br&gt;
&lt;script type="text/javascript"&gt;
var str = '';
for (var i=6001; i&lt;6044; i++) {
str += '&lt;input onclick="show_joke(' + "'" + i + "'" + ')"';
str += ' value="Show other(' + i + ') jokes" type="button"&gt;';
if ((i % 4) == 0) { str += '&lt;br&gt;'; }
}
document.write(str);
&lt;/script&gt;

&lt;p&gt; &lt;input onclick="answers()" value="Get answers" type="button"&gt;

&lt;br&gt;
1.&lt;div id="d1d"&gt;&lt;/div&gt;
2.&lt;div id="d2d"&gt;&lt;/div&gt;
3.&lt;div id="d3d"&gt;&lt;/div&gt;
4.&lt;div id="d4d"&gt;&lt;/div&gt;
5.&lt;div id="d5d"&gt;&lt;/div&gt;
6.&lt;div id="d6d"&gt;&lt;/div&gt;
7.&lt;div id="d7d"&gt;&lt;/div&gt;
8.&lt;div id="d8d"&gt;&lt;/div&gt;
9.&lt;div id="d9d"&gt;&lt;/div&gt;
10.&lt;div id="d10d"&gt;&lt;/div&gt;
&lt;br&gt;

&lt;form name="myform" action="" method="get" onsubmit="return false"&gt;
Your #(visitors use 5998):&lt;br&gt; &lt;input name="number" type="text"&gt; &lt;br&gt;
Joke number(if you haven't done any, it's 1, if you've done 1, it's 2 etc.):&lt;br&gt; &lt;input name="jnum" type="text"&gt;&lt;br&gt;
Your joke:&lt;br&gt; &lt;textarea name="joke" rows="5" cols="50"&gt;&lt;/textarea&gt;&lt;br&gt;
Answer(if you have one):&lt;br&gt; &lt;textarea name="an" rows="5" cols="50"&gt;&lt;/textarea&gt;&lt;br&gt;
&lt;input name="button1" value="Make your joke" onclick="submit(this.form)" type="button"&gt;
&lt;/form&gt;

&lt;!-- following scripts not supplied at this time
&lt;script type="text/javascript" src="http://images.webs.com/static/global/js/webs/usersites/escort.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;if(typeof(urchinTracker)=='function'){_uacct="UA-230305-2";_udn="none";_uff=false;urchinTracker();}&lt;/script&gt;
--&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@njaohntauthorJun 08.2011 — I will try it out. By the way, I can't use that javascript to make buttons, because I will have other content on the real page, so I can't use document.write, so I'll just put in the buttons. What's that <!--scripts not supplied at...--> for?
×

Success!

Help @njaohnt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...