Click here to Skip to main content
15,885,855 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am getting "Object expected" error for the below piece of code: in the line 14 Char 1, Please suggest.

HTML
<script type="text/javascript">
function First(){
alert("in First function");
}
function Second(){
alert("in Second function");
}

</script>
 
<table id="1234">
<tr><td><a  onclick="First()">First</a></td></tr>
<tr><td><a  onclick="Second()">Second</a></td></tr>
</table>
<table id="abcd">
<tr>
<td>Serial Number 1 :</td>
<td>abcd</td>
</tr>
</table>


Thanks in advance.

Regards,
Raghu
Posted
Updated 10-Sep-14 5:47am
v5
Comments
Sergey Alexandrovich Kryukov 11-Sep-14 0:43am    
Why not commenting that line 14? Can you use the Javascript debugger?
—SA

Hi,

I'm not sure what the ö character in your onclick attributes are, but I think these need to be changed to regular o

Something like ...
From:
HTML
<table><tbody><tr><td><a önclick="First()">First</a></td></tr></tbody></table>
<table><tbody><tr><td><a önclick="Second()">Second</a></td></tr></tbody></table>


To:
HTML
<table><tbody><tr><td><div onclick="First();">First</div></td></tr></tbody></table>
<table><tbody><tr><td><div onclick="Second();">Second</div></td></tr></tbody></table>


I've also swapped out your archor tags for divs, as it's not good practise to use an anchor tag without an href value.
I also added the missing semi-colons after the function call in the onclick methods.

Hope it helps.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Sep-14 0:42am    
This 'ö' is just the artifact of CodeProject formatting of the code. Chances are, OP's original code had 'o'.
Look: OP fixed it. But it works as expected.
—SA
pgrn.cs.dsce 11-Sep-14 7:17am    
Thanks Alex, perhaps the original code is large, i pasted a modified one.. Below is the code as is, please suggest :

<script type="text/javascript">
function showmyTable(){
document.getElementById("tabinfHide").style.display = "block";
document.getElementById("PackageExpandAnchor").style.display = "none";
document.getElementById("PackageHideAnchor").style.display = "block";
}
function HideTable(){
document.getElementById("tabinfHide").style.display = "none";
document.getElementById("PackageHideAnchor").style.display = "none";
document.getElementById("PackageExpandAnchor").style.display = "block";
}
</script>
<table id="tabinf">
<tr><td class="tdSpecialtitle" colspan="2">PACKAGE FOLDERS :</td></tr>
<tr><td class="tdinfError" colspan="2">NOTE : The Below folders are present in the folder: %ProgramData%\AppV\3E2E9B5B-8E7B-4665-A544-D47C8CB76EA8\E8806E62-BFF8-4AA9-B656-B4DFAB6233B2</td></tr>
<tr><td class="tdinfError" colspan="2">NOTE : Folders under VFS and Scripts folder are listed in bold Purple
Other folders are displayed in blue</td></tr>
<tr><td class="tdinfStitle" colspan="2"><div id="PackageExpandAnchor" önclick="ShowmyTable();" style="display:none">+ Expand Folders</td></tr>
<tr><td class="tdinfStitle" colspan="2"><div id="PackageHideAnchor" önclick="HideTable();">- Collapse Folders</td></tr>
</table>
<table id="tabinfHide">
<tr>
<td class="tdinfLWarning">Folder 1 :</td>
<td class="tdinfWarning"> Root\VFS\Profile\geoSCOUT\Templates\frameWORKs</td>
</tr>
</table>
Puzzled, I tried your code. It works as expected. Perhaps the problem is in your observations; or you used the code different from the code you published in your question.

—SA
 
Share this answer
 
In your code pasted above, you have named your function "showmyTable()" but when you are using it in the html part it is "ShowmyTable()".
Try the below code
JavaScript
<script type="text/javascript">
function ShowmyTable() //Change the name of the function from showmyTable() to ShowmyTable()
{
	document.getElementById("tabinfHide").style.display = "block";
	document.getElementById("PackageExpandAnchor").style.display = "none";
	document.getElementById("PackageHideAnchor").style.display = "block";
}
function HideTable(){
	document.getElementById("tabinfHide").style.display = "none";
	document.getElementById("PackageHideAnchor").style.display = "none";
	document.getElementById("PackageExpandAnchor").style.display = "block";
}
</script>

HTML
<table id="tabinf">
<tr>
	<td class="tdSpecialtitle" colspan="2">PACKAGE FOLDERS :</td>
</tr>
<tr>
	<td class="tdinfError" colspan="2">NOTE : The Below folders are present in the folder: %ProgramData%\AppV\3E2E9B5B-8E7B-4665-A544-D47C8CB76EA8\E8806E62-BFF8-4AA9-B656-B4DFAB6233B2</td>
</tr>
<tr>
	<td class="tdinfError" colspan="2">NOTE : Folders under VFS and Scripts folder are listed in bold Purple Other folders are displayed in blue</td>
</tr>
<tr>
	<td class="tdinfStitle" colspan="2"><div id="PackageExpandAnchor" önclick="ShowmyTable();" style="display:none">+ Expand Folders</div></td>
</tr>
<tr>
	<td class="tdinfStitle" colspan="2"><div id="PackageHideAnchor" önclick="HideTable();">- Collapse Folders</div></td>
</tr>
</table>
<table id="tabinfHide">
<tr>
	<td class="tdinfLWarning">Folder 1 :</td>
	<td class="tdinfWarning"> Root\VFS\Profile\geoSCOUT\Templates\frameWORKs</td>
</tr>
</table>


Hope it helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900