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
MartinKMartinK 

HTML Button Links in Visualforce

Hello,

 

I have a question regarding buttons in Visualforce.   I have an HTML button on a Visualforce page within a row in a page block table.  The code for the button is as follows

 

 

<FORM METHOD="LINK"
   ACTION= "https://na3.salesforce.com/a00/e?CF00N500000020AwV={!Request__c.name}  &CF00N500000020Ax9={!p.Account__r.name}">
   <INPUT TYPE="submit" VALUE="Select Refferal"/>
</FORM>

 

When the page is rendered and I inspect the element the URL reads as follows

 

<form action="https://na3.salesforce.com/a00/e?CF00N500000020AwV=bub&CF00N500000020Ax9=Houses" method="link"><input type="submit" value="Select Refferal"></form>

 I can cut and paste this URL into my browser and the new page is properly launched.

 

However, when I click on the button in the Visualforce page, I am sent to the following URL with the Query string parameters missing.

https://na3.salesforce.com/a00/e?

 

Why do the query string parameters get dropped? What can I do about it.

 

Thank you in advance for your help.

 

 

gtuerkgtuerk

Looks like you have  a space after your first query string parameter.  try removing that.  Also, I'd use the EncodeUtil class to encode the Name field if you ever expect special characters...

MartinKMartinK

Hello,

Thanks for your quick response. I do not have any spaces in the URL string (for display purposes in the discussion I added one) nor do I have any special characters. The Query string parameters work when I apply them as a custom button in Salesforce and when I cut and paste the URL from the rendered page.  I also tried a test where I took the HTML button code out and put it on a regular HTML page, this did not work.  The button code is below.

 

 

 <INPUT TYPE="submit" VALUE="Select Refferal" />
 </FORM>

 

 <FORM ACTION="https://na3.salesforce.com/a00/e?CF00N500000020AwV=test" METHOD="LINK"> <INPUT TYPE="submit" VALUE="Select Refferal" /> </FORM> 

 

Is this the correct way to create an HTML button in Visual Force?