/    Sign up×
Community /Pin to ProfileBookmark

Div Change Text Not Working

I am trying to change the text in a div. Here is the script affected in the head:

[quote]

var insideprice = 639
var caseprice = 0
var casecolor
var osprice = 90
var Sdellprice = “1500.00”
var dellprice = 1500
var totalprice = Math.round(((1.030745814 * (insideprice + caseprice + osprice + 100)) + 2.263622527) * 100)/100
var savings = Math.round((dellprice – totalprice)*100)/100
var compcase
var compcolor
function ChangeDivText() {
totalprice = Math.round(((1.030745814 *
(insideprice + caseprice + osprice + 100)) + 2.263622527) * 100)/100
savings = Math.round((dellprice – totalprice)*
100)/100
document.all[‘Dellid’].innertext = document.write(Sdellprice);
document.all[‘Sigmaid’].innertext = document.write(totalprice);
document.all[‘Savingsid’].innertext = document.write(savings);
}

[/quote]

This (the quote on top) is called by this function:

[quote]

function ChangeOption2(sel) {
compcase = sel.options[sel.selectedIndex].lastChild.nodeValue;
sel3 = document.getElementById(“colorselect”)
if (compcase==”X-Dreamer II”) {
document.getElementById(“color1”).lastChild.nodeValue= “Black”
document.getElementById(“color2”).lastChild.nodeValue= “Silver”
document.getElementById(“color3”).lastChild.nodeValue= “Blue”
document.getElementById(“color4”).lastChild.nodeValue= “Green”
document.getElementById(“color5”).lastChild.nodeValue= “——“
document.getElementById(“color6”).lastChild.nodeValue= “——“
document.getElementById(“color7”).lastChild.nodeValue= “——“
document.getElementById(“choosei”).src= “../Images/Cases/xdreamerII.jpg”
colorvar(sel3)
caseprice = 0
ChangeDivText()
}
……………………….(on and on)

[/quote]

Here is the select statement which activates the functions (the one on top)

[quote]

<div id=”Layer3″ style=”position:absolute; left:423px; top:339px; width:131px; height:27px; z-index:4; background-color: #333333; layer-background-color: #333333; border: 1px none #000000;”>
<div align=”left”>
<select name=”cases” onchange=”ChangeOption2(this)”>
<option>Choose Your Case</option>
<option>X-Dreamer II</option>
<option>X-Infinity</option>
<option>Enermax MT</option>
<option>X-Alien</option>
<option>Sonata</option>
<option>X-Super Alien</option>
</select>
</div>
</div>

[/quote]

and this is the div statements that are affected

[quote]

<div align=”center” id=”Dellid” style=”position:absolute; left:427px; top:272px; width:110px; height:20px; z-index:15; background-color: #333333; layer-background-color: #333333; border: 1px none #000000;” class=”style17″>
$<script type=”text/javascript”> document.write(Sdellprice) </script>
</div>
<div align=”center” id=”Sigmaid” style=”position:absolute; left:427px; top:307px; width:110px; height:19px; z-index:15; background-color: #333333; layer-background-color: #333333; border: 1px none #000000;” class=”style17″>
$<script type=”text/javascript”> document.write(savings)</script>
</div>
<div align=”center” id=”Savingsid” style=”position:absolute; left:427px; top:289px; width:110px; height:20px; z-index:15; background-color: #333333; layer-background-color: #333333; border: 1px none #000000;” class=”style17″>
$<script type=”text/javascript”> document.write(totalprice) </script>
</div>

[/quote]

For some reason this does not work on my page. It keeps giving an error: A runtime error has occurred. Do you wish to debug? Line: 73 Error: ‘document.all.Sigmaid” is null or not an object.

Any help would be awesome. Thanks!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJun 30.2004 — First, document.all is an IE only object. You should use document.getElementById consistently.

Second, you should not do this:document.all['Dellid'].innertext = document.write(Sdellprice);[/quote]
Instead, use:document.getElementById('Dellid').innerHTML = Sdellprice;I changed to innerHTML, since innerText is also IE only.
Copy linkTweet thisAlerts:
@theuedimasterauthorJun 30.2004 — thanks man!
×

Success!

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