Jump to content

Form submit stay in tab issue


Ashleyfh

Recommended Posts

HI there i am having trouble with some code hope someone can help, i have a webpage with in the page has 7 tabs, on the 7th tab is 3 button eavh one does something different, one will restart the server once pressed one turns it on and one off.

 

soo when i press the button it all works just i need it to be able to stay on that tab and not refresh the page back to the first tab

 

here is a sample of my code:

 

<form method="post" action="{$smarty.server.PHP_SELF}?action=productdetails">
   <input type="hidden" name="id" value="{$id}" />
   <input type="submit" name="turnoff" value="Power Off">
</form>
                    
             </td>

 {php}
                    

                      if(isset($_POST['turnoff'])) {
                      $customfield = $this->get_template_vars('customfield');
                      $RemoteReboot = explode(",", $customfield['value']);
                      $mib = ".1.3.6.1.4.1.13742.4.1.2.2.1.3.";
                      $mib = $mib.$RemoteReboot[1];
                      $community = "hjkuiouYUI23";
                      $result = snmpset($RemoteReboot[0], $community, $mib, i, "0");
                            
                       #echo($result);
                     }

  {/php}

Link to comment
https://forums.phpfreaks.com/topic/291704-form-submit-stay-in-tab-issue/
Share on other sites

you need to understand that submitting a form on a stateless page will refresh the page. You want to asynchrousnly submit the data ( submit without reloading the page ) . SO look at using ajax

Thanks for your answer, with ajax do you have to use it on seperate file and link it with my php ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.