/    Sign up×
Community /Pin to ProfileBookmark

text boxes just will not refresh

Why oh why will those text boxes not refresh? I can’t even get them to change for any reason, I’ve tried deleting all the functions and just leaving the text boxes, but they won’t change even then.

<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Adventure</title>
<script type=”text/javascript”>
dec = 0; dun = 0; cha = 0;
bat = 0; scen = 0; sscen = 0; mscen = 1;

function random(maxnum)
{
r = Math.random() * maxnum;
if (r > maxnum)
r = maxnum;
return r;
}

function init()
{
refresh();
}

function round(number)
{
r = number;
r = Math.round(r);
return r;
}

function refresh()
{
if (bat == 0)
{
if (scen == 0)
{
sscen = 0;
scen = round(random(mscen – 1)) + 1;
}
if (scen == -1)
{
sscen = 0;
form.maintext.value = “You are dead!”;
form.optonetext.value = “Play again?”;
form.opttwotext.value = “”:
form.optthrtext.value = “”:
form.optfoutext.value = “”;
form.optfivtext.value = “”;
}
if (scen == 1)
{
if (sscen == 0)
{
form.maintext.value = “There is an ogre attacking you.”;
form.optonetext.value = “Flee!”;
form.opttwotext.value = “Fight him.”;
form.optthrtext.value = “Mating Season!”;
form.optfoutext.value = “”;
form.optfivtext.value = “”;
}else if (sscen == 1)
{
form.maintext.value = “He catches you and eats you.”;
form.optonetext.value = “Continue.”;
form.opttwotext.value = “”;
form.optthrtext.value = “”;
form.optfoutext.value = “”;
form.optfivtext.value = “”;
}
}
}
}

function optionOne()
{
if (scen == -1)
{
scen = 0; bat = 0;
init();
}
if (scen == 1)
{
if (sscen == 0)
{
sscen = 1;
}else if (sscen == 1)
{
scen = -1;
}
}
refresh();
}

function optionTwo()
{
}

function optionThr()
{
}

function optionFou()
{
}

function optionFiv()
{
}

function chanceOutOf(num)
{
rer = num;
der = 0;
cer = random(1);
con = 1/rer;
if (cer <= con)
der = 1;
return der
}

</script>
</head>
<body onload=”init()”>
<center>
<form name=”form” id=”form” action=””>
<textarea cols=”50″ rows=”4″ name=”maintext” value=”There is an ogre attacking you.”></textarea>
<br>
<input type=”button” value=”Option 1.” onclick=”optionOne()”>
<br>
<textarea cols=”20″ rows=”1″ name=”optonetext” value=”Flee!”></textarea>
<br>
<input type=”button” value=”Option 2.” onclick=”optionTwo()”>
<br>
<textarea cols=”20″ rows=”1″ name=”opttwotext” value=”Fight him.”></textarea>
<br>
<input type=”button” value=”Option 3.” onclick=”optionThr()”>
<br>
<textarea cols=”20″ rows=”1″ name=”optthrtext” value=”Mating Season!”></textarea>
<br>
<input type=”button” value=”Option 4.” onclick=”optionFou()”>
<br>
<textarea cols=”20″ rows=”1″ name=”optfoutext” value=”BLAGH!”></textarea>
<br>
<input type=”button” value=”Option 5.” onclick=”optionFiv()”>
<br>
<textarea cols=”20″ rows=”1″ name=”optfivtext” value=””></textarea>
<br>
<input type=”button” value=”Refresh.” onclick=”refresh()”>
</form>
</center>
</body>
</html>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@justinbarneskinDec 03.2009 — textareas are not set with values inside the tag see code

[code=html]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Adventure</title>
<script type="text/javascript">
var dec = 0; var dun = 0; var cha = 0;var bat = 0;var scen = 0;var sscen = 0;var mscen = 1;

function random(maxnum){
r = Math.random() * maxnum;
if (r > maxnum)
r = maxnum;
return r;
}

function init(){ refresh(); }

function round(number){
r = number;
r = Math.round(r);
return r;
}

function refresh(){alert('problem in refresh() function')
/*
if (bat == 0){
if (scen == 0){
sscen = 0;
scen = round(random(mscen - 1)) + 1;
}
if (scen == -1){
sscen = 0;
form.maintext.value = "You are dead!";
form.optonetext.value = "Play again?";
form.opttwotext.value = "":
form.optthrtext.value = "":
form.optfoutext.value = "";
form.optfivtext.value = "";
}
if (scen == 1){
if (sscen == 0){
form.maintext.value = "There is an ogre attacking you.";
form.optonetext.value = "Flee!";
form.opttwotext.value = "Fight him.";
form.optthrtext.value = "Mating Season!";
form.optfoutext.value = "";
form.optfivtext.value = "";
}
else if (sscen == 1){
form.maintext.value = "He catches you and eats you.";
form.optonetext.value = "Continue.";
form.opttwotext.value = "";
form.optthrtext.value = "";
form.optfoutext.value = "";
form.optfivtext.value = "";
}
}
}
*/
}

function optionOne(){
if (scen == -1){
scen = 0; bat = 0;
init();
}
if (scen == 1){
if (sscen == 0){ sscen = 1; }
else if (sscen == 1){ scen = -1; }
}
refresh();
}

function optionTwo(){alert('2') }

function optionThr(){alert('3') }

function optionFou(){alert('4') }

function optionFiv(){alert('5') }

function chanceOutOf(num){
rer = num;
der = 0;
cer = random(1);
con = 1/rer;
if (cer <= con){ der = 1; }
return der
}

</script>
</head>
<body onload="init()">
<center>
<form name="form" id="form" action="">
<textarea cols="50" rows="4" name="maintext">There is an ogre attacking you.</textarea>
<br>
<input type="button" value="Option 1." onclick="optionOne()">
<br>
<textarea cols="20" rows="1" name="optonetext">Flee!</textarea>
<br>
<input type="button" value="Option 2." onclick="optionTwo()">
<br>
<textarea cols="20" rows="1" name="opttwotext" >Fight him.</textarea>
<br>
<input type="button" value="Option 3." onclick="optionThr()">
<br>
<textarea cols="20" rows="1" name="optthrtext">Mating Season!</textarea>
<br>
<input type="button" value="Option 4." onclick="optionFou()">
<br>
<textarea cols="20" rows="1" name="optfoutext">BLAGH!</textarea>
<br>
<input type="button" value="Option 5." onclick="optionFiv()">
<br>
<textarea cols="20" rows="1" name="optfivtext" ></textarea>
<br>
<input type="button" value="Refresh." onclick="refresh()">
</form>
</center>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@justinbarneskinDec 03.2009 — If I had any passion for this, I would do it this way...

[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD><TITLE>Adventure</TITLE>
<script type="text/javascript">
var haps=['There is an ogre attacking you.','He catches you and eats you.','You are dead!','Play again?','Avert your itty bitty eyes','','','']
var reacts=['Flee!','Fight him','Mating Season!','Blagh','','','','','','','','','','','','','','']

function stage(x,y){ var s='<select onchange="opts(document.getElementById('scene'),this.selectedIndex);" >';
s+='<OPTGROUP id="choices" label="What to do?"></OPTGROUP>';
for(i=x;i<y;i++){s+='<option>'+reacts[i]+'</option>'}
document.getElementById('op').innerHTML=s+'</select>'; document.forms[0].elements[0].size=document.forms[0].elements[0].options.length+1;
document.forms[0].elements[0].selectedIndex=-1
}

function opts(s,o){
if(s.innerHTML==haps[0]){
if(o==0){s.innerHTML=haps[1]; }
else if(o==1){s.innerHTML=haps[4]; }
else if(o==2){s.innerHTML=haps[3]; }
else if(o==3){s.innerHTML=haps[2]; }
return}
else if(s.innerHTML==haps[1]){
if(o==0){s.innerHTML=haps[0]; }
else if(o==1){s.innerHTML=haps[0]; }
else if(o==2){s.innerHTML=haps[0]; }
else if(o==3){s.innerHTML=haps[0]; }
return}
else if(s.innerHTML==haps[2]){
if(o==0){s.innerHTML=haps[0]; }
else if(o==1){s.innerHTML=haps[0]; }
else if(o==2){s.innerHTML=haps[0]; }
else if(o==3){s.innerHTML=haps[0]; }
return}
else if(s.innerHTML==haps[3]){
if(o==0){s.innerHTML=haps[0]; }
else if(o==1){s.innerHTML=haps[0]; }
else if(o==2){s.innerHTML=haps[0]; }
else if(o==3){s.innerHTML=haps[0]; }
return}
else if(s.innerHTML==haps[4]){
if(o==0){s.innerHTML=haps[0]; }
else if(o==1){s.innerHTML=haps[0]; }
else if(o==2){s.innerHTML=haps[0]; }
else if(o==3){s.innerHTML=haps[0]; }
return}

}

</script>
</head>
<body onload="stage(0,4)">

<form name="form" id="form" action="" style="text-align:center">
<div id="scene" style="text-align:center;color:navy;font-size:32px;padding:15px">There is an ogre attacking you.</div>

<div id="op"></div>

</form>

</body>
</html>[/code]
Copy linkTweet thisAlerts:
@slaughtersDec 03.2009 — Give your textarea tags an ID that matches the name, like:

[CODE]<textarea cols="20" rows="1" name="optfivtext" id="optfivtext"></textarea>[/CODE]

Then in your refresh() function set their value property to an empty string
[CODE]
document.getElementById("optfivtext").value = "";[/CODE]
×

Success!

Help @Neurotheist 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,
)...