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
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 ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.