+ Start a Discussion
ABakABak 

javascript issue

havent used javascript before so I am testing a bare basic example but it wont work. Any suggestions would be helpful.

Also if someone can link me to some good examples of using javascript with visualforce , it will be great

<apex:pageBlockButtons id="pbButtons" location="bottom">
				<apex:commandButton id="btnSave" value="Save" onclick="javascript&colon;checkIds()"/>
				<apex:commandButton id="btnCancel" value="Cancel" action="{!loadOppPage}"/>
				<script src="/soap/ajax/15.0/connection.js" type="text/javascript">
					var btnSave = document.getElementById("{!$Component.btnSave}");
					funciton checkIds()
					{
						window.alert('this works');
					}
				</script>
			</apex:pageBlockButtons>

 

 

imuino2imuino2

First of all i recommend you to use some javascript library, like jQuery. It is easy to use and learn at makes javascript much more easy.

Some tips:

       Dont catch elements by its ids if it are apex components, because the id is changed in the page proccess.

       With jQuery you can catch it by class.

       Or do it by the name.

 

Here is an example of how to do it:

      http://www.salesforce.com/us/developer/docs/pages/Content/pages_access.htm

 

Ignacio.