1

I am using LDS + VF pages to make a simple calculator. Pressing a button at the bottom will set a flag in the controller and that flag will render an element and un-render another. For rendering, I NEED <apex:form> tag.

**EDIT : ** Button code is here...

As you can see, pretty simple work.

I am using LDS + CSS to style the buttons (CSS file in a static resource).

I have a <div class="slds-grid"> that holds three (3) <div class="slds-col">.

Inside each sdls-col there are custom buttons styled via CSS. Clicking them changes a <div> via document.getElementById("Display_Div_Id");.

When I add <apex:form> tags ANYWHERE in the page, the FIRST and SECOND slds-col and its buttons behave VERY weird.

They change the Display_Div_Id AND refresh the page. This is ESPECIALLY weird since the buttons in the third slds-col are very simple/dummy/mockup buttons with NO code/logic.

They should not even be changing ANYTHING.

What I require :

  1. Why the page is behaving weird.
  2. A way to render elements without using <apex:form>

As always, thanks for reading. (pls dont edit, im trying to be polite to ppl who spend their time to help me)

  • Can you add the button mark up ? Thanks – Mohith Shrivastava Aug 29 '16 at 4:42
  • Yes ofc, you will have to wait, though, I will take a few minutes and add it to the OP – fraglord Aug 29 '16 at 4:43
2

When you are adding apex:form ,the button by default is rendering of type=submit .Use the Type attribute to specify its just of type of button .

Change your button code to below

<button id="lightbluebutton5" type="button" onclick="show_amt_leftbutton(10)" style="height:65px" class="button slds-size--3-of-5">10</button>

Notice how i have added an attribute to explicitly mention that it is of type=button to avoid submit of the form by default .

| improve this answer | |
  • OH!!! Now I understand what was going wrong (my "buttons" in the 2nd column were just divs with an onclick attribute :) )! Thank you! Just perfect! – fraglord Aug 29 '16 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.