如何记住用于PHP表单提交的最后一个标签?

时间:2017-12-04 12:16:10

标签: php jquery

我在其中一个标签中有一个表单,但是当它提交时会返回到第一个表单。

library(shiny)

Dat<-read.csv("A:\\home\\Documents\\Franchise_Failureby_Brand2011.csv", sep=';')
names(Dat)[1]<-paste("Brand")
names(Dat)[2]<-paste("Failure")
names(Dat)[3]<-paste("Disbursement")
names(Dat)[4]<-paste("Disb$X$1000")
names(Dat)[5]<-paste("Chgoff")
Dat1<-Dat[is.na(Dat)==FALSE,]
Dat<-Dat1[1:578,]

# Define server logic required to draw a histogram
shinyServer(function(input, output) {
  DatSv <- reactive({
    switch(input$n,
          "Failure"= gsub("%","",as.character(    Dat$Failure)),
          "Disbursement"=Dat$Disbursement,
          "Disb$X$1000"=gsub("\\$","",as.character(    Dat$`Disb$X$1000`)),
          "Chgoff"=gsub("%","",as.character(Dat$Chgoff)))

  })

  # Generate plot 
  output$plot1 <- renderPlot({
    library("quantmod")
    hist(as.numeric(DatSv()),
         main=paste('Histogram of ',input$n, sep=''),
         xlab = input$n)
  })

  # Generate summary of data

  output$summary<-renderPrint({
    summary(Dat)
  }) 

})

PHP获取表单并更新数据库并重定向:

<div class="panel panel-primary">
    <div class="panel-heading">
        <div class="panel-control">
            <ul class="nav nav-tabs">
                <li class="active"><a data-toggle="tab" href="#tab" aria-expanded="true">Tab1</a></li>
                <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">Tab2</a></li>
            </ul>
        </div>
        <h3 class="panel-title">Text</h3>
    </div>
    <div class="panel-body">
        <div class="tab-content">
            <div id="tab" class="tab-pane fade active in">
                <form class="form-group" method="post" action="#" enctype="multipart/form-data">
                    <input class="form-control description" name="description[]" placeholder="Description here">
                    <input class="btn btn-primary btn-lg" name="update" type="submit" value="Save">
                </form>
            </div>
            <div id="tab-2" class="tab-pane fade">

            </div>
        </div>
    </div>
</div>

链接是正确的,但是标签不会使用url中的#tab更新,任何人都有其他方法可以将活动标签设置为上次使用的标签吗?

1 个答案:

答案 0 :(得分:0)

使用以下代码...可能对您有所帮助,因为它对我而言......

$('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
  localStorage.setItem('activeTab', $(e.target).attr('href'));
});
var activeTab = localStorage.getItem('activeTab');
if(activeTab){
  $('#action-tab a[href="' + activeTab + '"]').tab('show');
}