function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rohit AlladiRohit Alladi 

java.lang.IllegalArgumentException: Illegal view ID myfunction(). The ID must begin with /

my visual force page:

<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<p id= "demo"> hello
</p>
<apex:inputField value="{!borrower__c.borrowers_name__c}"/>
<apex:inputField value="{!borrower__c.borrowers_id__c}" id="eng"/>
<apex:inputField value="{!borrower__c.current_year__c}" id="mat"/>
<apex:inputField value="{!borrower__c.Staff__c}" id="sci" onchange="showhidefield();"/>
<apex:inputField value="{!borrower__c.ADDRESS__c}" id="soc"/>
<apex:commandButton value="click me" action="myfunction()"/>

</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

 

 

my java script :

 

<script language="JavaScript">
function showhidefield()
{

if (document.getElementById("j_id0:j_id2:j_id3:j_id4:sci").checked)
{
document.getElementById("j_id0:j_id2:j_id3:j_id4:eng").style.visibility = "hidden";


}
else
{
document.getElementById("j_id0:j_id2:j_id3:j_id4:eng").style.visibility = "visible";

}
}
function myFunction()
{
x=document.getElementById("demo") // Find the element
x.style.color="#ff0000"; // Change the style
}
</script>

 

 

can any one let me know where i went wrong ??? 

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

Well I guess you are making a basic mistake here

 

<apex:commandButton value="click me" action="myfunction()"/>

 The action attribute binds controller methods, in your case you are binding js function.

 

So to call a jsfunction you can use the onclick event. Something like this 

 

<apex:commandButton value="click me" onclick="myfunction();return false;"/>

 

All Answers

souvik9086souvik9086

Hi,

 

http://boards.developerforce.com/t5/Visualforce-Development/java-lang-IllegalArgumentException-Illegal-view-ID-this-is-next/td-p/257249

 

You can find it in this thread.

 

If this post solves your problem kindly mark it as solution. if this post is helpful please throw Kudos.

Thanks

Avidev9Avidev9

Well I guess you are making a basic mistake here

 

<apex:commandButton value="click me" action="myfunction()"/>

 The action attribute binds controller methods, in your case you are binding js function.

 

So to call a jsfunction you can use the onclick event. Something like this 

 

<apex:commandButton value="click me" onclick="myfunction();return false;"/>

 

This was selected as the best answer