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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript Error - Object Expected 1

Status
Not open for further replies.

craigward

Programmer
Nov 13, 2007
230
GB
Hi,

I found some script on the net that will update a text field with the values from selected checkboxes. It stores the value between pages and wil remove items if the users unchecks a box.

I am very poor with JavaScript and keep getting an error saying object expected.

Can anyone see an obvious issue with the following code?

Thanks for any help.


JavaScript

Code:
Dim myvalue
function mytester(myvalue,myname){
	
	tester='document.getElementById("'+myname+'").checked'
if (eval(tester)){
if (document.mailerlookup.compareitems.value==''){
	document.mailerlookup.compareitems.value=','+myvalue+','
}
else{
	document.mailerlookup.compareitems.value = document.mailerlookup.compareitems.value+myvalue+','
	}
}
else{
	document.mailerlookup.compareitems.value = document.mailerlookup.compareitems.value.replace(','+myvalue+',', '');
	}
}

Checkboxes, displayed through ASP pulling records from the database.

Code:
Response.Write("<tr><td bgcolor='" & strBGColour & "'><input type='checkbox' id='checkbox1863' name='checkbox1863' value='" & objRS("uniqueid") & "' onClick='javascript:mytester(this.value,this.name)' /></td><td bgcolor='" & strBGColour & "'>" & objRS("contact") & "</td><td bgcolor='" & strBGColour & "'>" & objRS("rooms_from") & "</td><td bgcolor='" & strBGColour & "'>" & objRS("idstatus") & "</td><td bgcolor='" & strBGColour & "'>" & objRS("price_from") & "</td><td bgcolor='" & strBGColour & "'>" & objRS("price") & "</td></tr>")

Text field

Code:
<input type="text" name="compareitems" />
 
That helped :p Thanks

Still getting the error but the lines doesn't refer to any of the code.

I think it is related to this line.

Code:
    document.mailerlookup.compareitems.value=','+myvalue+','

if i replace itwith an alert("test") i get the alert.

Does that help?

Thanks
 
I actually tried alert(myvalue) and i get the result i was expecting, it just won't populate the text field, with

document.mailerlookup.compareitems.value=','+myvalue+','
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top