/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] FireFox not updating innerHTML

This code is generated from a PHP form. I’m certain something simple is awry here but the following code works in IE, but not FireFox.

[code=php]

<script language=”JavaScript”>
var aPackageNames = new Array()
var aPackageDescriptions = new Array()
var aPackagePrices = new Array()

aPackageNames[0] = ” ”
aPackageDescriptions[0] = ” ”
aPackagePrices[0] = ” ”

aPackageNames[1] = “Test Package”
aPackageDescriptions[1] = “Praesent orci sapien, faucibus eget, mattis vel, pharetra ac, ante. Suspendisse ultrices. Nulla facilisi. Quisque venenatis felis ut lectus. Praesent eu enim. Suspendisse ultricies sollicitudin tellus. Sed id velit. Integer interdum. Ut nisl tortor, congue in, volutpat at, scelerisque at, metus. Nunc convallis vehicula quam. Fusce velit mi, aliquet et, gravida sit amet, semper sit amet, tortor. Nullam accumsan tincidunt nulla. Sed lobortis urna vitae ipsum.”

aPackagePrices[1] = “125”
aPackageNames[2] = “Test Package 2”
aPackageDescriptions[2] = “Test Package”
aPackagePrices[2] = “1234”

aPackageNames[3] = “Test Package 3”
aPackageDescriptions[3] = “Test Package 3”
aPackagePrices[3] = “99.99”

aPackageNames[4] = “Test Package 4”
aPackageDescriptions[4] = “Test Package 4”
aPackagePrices[4] = “140”

aPackageNames[5] = “Test Package 5”
aPackageDescriptions[5] = “Test Package 5”
aPackagePrices[5] = “66.5”

aPackageNames[6] = “Test Package 6”
aPackageDescriptions[6] = “Test Package 6”
aPackagePrices[6] = “987.99”

function ShowDescription(i)
{
document.getElementById(‘hidPackagePlanName’).value = aPackageNames[i]
document.getElementById(‘lblDescription’).innerHTML = aPackageDescriptions[i]
document.getElementById(‘lblPrice’).innerHTML = aPackagePrices[i]
}
</script>
<body>
<form>
<table width=”500″>
<tr>
<th width=”150″>Package Plan</th>
<td align=”left” width=”350″>
<select name=”ddlPackagePlan” onChange=”ShowDescription(this.selectedIndex)”><option value=”” selected>Select a package</option><option value=”1″>Test Package</option><option value=”2″>Test Package 2</option><option value=”3″>Test Package 3</option><option value=”4″>Test Package 4</option><option value=”5″>Test Package 5</option><option value=”6″>Test Package 6</option></select><span style=”color: #ff0000;”>*</span> </td>

</tr>
<tr>
<td align=”right”>Price&nbsp;&nbsp;</td>
<td><div id=”lblPrice”>&nbsp;</div></td>
</tr>
<tr>
<td align=”right” valign=”top”>Description&nbsp;&nbsp;</td>
<td><div id=”lblDescription”>&nbsp;</div></td>

</tr>
</table>
<input type=”hidden” name=”hidPackagePlanName”>
</form>
[/code]

By works I mean if you select a package from the dropdown, it should populate the “Price” and “Description” boxes accordingly.

Can anyone see what might be wrong here? I’ve tried replacing .innerHTML with .firstChild.nodeValue but that doesn’t work either. My best guess is I’m not using the properties correctly.

Thank you for your time. Any help is appreciated.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisSep 23.2008 — Did you look at the javascript console?

Error: document.getElementById("hidPackagePlanName") has no properties

Source File: file:///J:/requests/gil/example/showDescription.htm

Line: 37
Copy linkTweet thisAlerts:
@YourChildSep 23.2008 — Yes, change your line of code before the </form> to:

<input type="hidden" name="hidPackagePlanName" id="hidPackagePlanName" value="">

you were missing the id and value attribute.

If you haven't done so, try using firefox as your main development browser. The firebug is a really great debugging tool for javascript.
Copy linkTweet thisAlerts:
@Mr_RoughauthorSep 23.2008 — Thank you guys. I figured it was something simple. For some reason it didn't give me an error from FireBug so I never checked that. I forgot to turn it on for the site.
×

Success!

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