Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.getElementById( ) has no properties 1

Status
Not open for further replies.

TheCandyman

Technical User
Sep 9, 2002
761
US
I'm trying to get this javascript to work when the drop down menu changes to pull a description and display it(splitString[3]). But i keep getting an error and no text. I made a message box to make sure my values where correct and i do need to display splitString[3] in Div 'thursdesc'. Where did i go wrong?

My Error:
document.getElementById(sDay + "thursdesc") has no properties

Code:
<script language="JavaScript" type="text/JavaScript">
	function updateinfo(sDay, iEventString, iQuant){
		if ( iEventString =="0"){
			document.getElementById(sDay + "div").innerHTML 		= "";
			document.getElementById(sDay + "subtot").innerHTML 	= "";
			//document.getElementById(sDay + "availdiv").innerHTML 	=  "";
		}
		else {
			var myString = new String(iEventString);
			var splitString = myString.split(':');
			document.getElementById(sDay + "div").innerHTML 		= "$" + splitString[1] + ".00";
			document.getElementById(sDay + "subtot").innerHTML 	= "$" + (splitString[1] * iQuant) + ".00";
			document.getElementById(sDay + "thursdesc").innerHTML 	=  splitString[3];
		};
	};
 </script>

Code:
<tr> 
    <td align="center" bgcolor="#E0E0E0" width="64"><span class="style12">Thurs</span> </td>
    <td height="30" align="center" width="319"> <select name="thursevent" id="thursevent" style="width:320px" onChange="updateinfo('thurs', this.value, document.modform.thursquant.value);" >
        <option value="0"> -- Please Select a Thursday Event to Attend -- </option>                 
	<option value="168:100:36:Description Text Goes Here"> 1:30pm - Advanced Composite Veneers (must attend a.m. lecture)</option>							
	<option value="181:20:50:">2:00pm - Biolase Workshop (AM lecture required)</option>														<option value="184:10:0:" style='color: #FF0000'>11:00am -  &nbsp;**&nbsp;SOLD OUT&nbsp;**&nbsp; Box Lunch on the Exhibit Floor</option>
       </select></td>
    <td colspan="3" rowspan="2" height="30">Desc: <div name="thursdesc" id="thursdesc"></div></td>
    <td align="center"><input name="Add1" type="button" id="Add1" onClick="addevent(document.modform.thursevent.value, document.modform.thursquant.value, document.modform.thursdesc.value);" value="Add This Event" style="font-family: Tahoma; font-size: 12px" /></td>
</tr>
<tr>
    <td align="left" colspan="3">              
	<table width="400" border="0" cellspacing="2" cellpadding="0">
		<tr>
		<td width="25%">&nbsp;</td>
		<td width="25%" align="center"><strong>Price:</strong> <div class="style1" id="thursdiv">$0.00</div></td>
		<td width="25%" align="center"><strong>Quanity:</strong> 
		<select name="thursquant" id="thursquant" onChange="updateinfo('thurs', document.modform.thursevent.value, this.value)">
			<option selected value="1" >1</option>					                            
			<option value="2">2</option>
			<option value="3">3</option>					                            
			<option value="4">4</option>					                            
			<option value="5">5</option>
		</select></td>
		<td width="25%" align="center"><strong>Subtotal:</strong><div class="thurssubtot" id="thurssubtot">$0.00</div></td>
		</tr>
	</table>
    </td>
</tr>
 
Would you confirm that your code validates against the doctype you are using? And why not let us know what browser you are getting these results with?

To fix your problem I would use Firefox and Firebug (the extension)... assuming it will give you more details on resolving it.

I reckon it can't deal with the fact you gave the div a name attribute.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Surely this:

Code:
document.getElementById(sDay + "thursdesc").innerHTML     =  splitString[3];

should be:

Code:
document.getElementById(sDay + "desc").innerHTML     =  splitString[3];

(i.e. without the "thurs")?

Otherwise, you'd be looking for a DIV with an id of "thursthursdesc".

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
You found it BillyRayPreachersSon, I overlooked that and now it works! Thx!!
 
Forgot to ask, in the above example, the js passes a url back to a div for a link. Is there another way to do this without using a div? I have tried several lightbox variations and none of them work with a div link.
 
Doesn't help, they are working on reloading the page, i'm trying not to do that, but have it the other way around.

Just wondering if it's possible do use that code, but send it to something else then a div
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top