Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts

    PHP link not passing Variable to form modal

    I have a table populated by MYSQL results, and at the end of the table is a php link that once clicked opens a modal form for some additional information to be added.

    The php link is shown below:

    PHP Code:
    echo "<a href=\"?ip_address=".$ip_address."#accSettings1\" role=\"button\" class='btn btn-small btn-primary hidden-tablet hidden-phone' data-toggle='modal'>Add</a>"
    in the above link the #accSettings1 is the trigger for the modal form, this works perfectly but if the link is clicked the form opens but the variable isn't passed to the form, nor does the variable get passed through the address bar.

    now if i take out the

    PHP Code:
    data-toggle='modal' 
    then the variable ip_address appears in the address bar like so:

    PHP Code:
    raw_data1.php?ip_address=207.16.80.128#accSettings1 
    but because i have removed the data-toggle the modal box doesn't open.

    does anybody have any ideas?

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,479
    Thanks
    0
    Thanked 635 Times in 625 Posts
    What does the HTML look like when you view the source of the page?
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok this line is the start of the modal box;

    Code:
    <div id="accSettings1" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    Heres the jquery

    Code:
    }
    
    Modal.prototype = {
    
      constructor: Modal
    
    , toggle: function () {
        return this[!this.isShown ? 'show' : 'hide']()
      }
    
    , show: function () {
        var that = this
          , e = $.Event('show')
    
        this.$element.trigger(e)
    
        if (this.isShown || e.isDefaultPrevented()) return
    
        this.isShown = true
    
        this.escape()
    
        this.backdrop(function () {
          var transition = $.support.transition && that.$element.hasClass('fade')
    
          if (!that.$element.parent().length) {
            that.$element.appendTo(document.body) //don't move modals dom position
          }
    
          that.$element
            .show()
    
          if (transition) {
            that.$element[0].offsetWidth // force reflow
          }
    
          that.$element
            .addClass('in')
            .attr('aria-hidden', false)
    
          that.enforceFocus()
    
          transition ?
            that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
            that.$element.focus().trigger('shown')
    
        })
      }
    
    , hide: function (e) {
        e && e.preventDefault()
    
        var that = this
    
        e = $.Event('hide')
    
        this.$element.trigger(e)
    
        if (!this.isShown || e.isDefaultPrevented()) return
    
        this.isShown = false
    
        this.escape()
    
        $(document).off('focusin.modal')
    
        this.$element
          .removeClass('in')
          .attr('aria-hidden', true)
    
        $.support.transition && this.$element.hasClass('fade') ?
          this.hideWithTransition() :
          this.hideModal()
      }
    
    , enforceFocus: function () {
        var that = this
        $(document).on('focusin.modal', function (e) {
          if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
            that.$element.focus()
          }
        })
      }
    
    , escape: function () {
        var that = this
        if (this.isShown && this.options.keyboard) {
          this.$element.on('keyup.dismiss.modal', function ( e ) {
            e.which == 27 && that.hide()
          })
        } else if (!this.isShown) {
          this.$element.off('keyup.dismiss.modal')
        }
      }
    
    , hideWithTransition: function () {
        var that = this
          , timeout = setTimeout(function () {
              that.$element.off($.support.transition.end)
              that.hideModal()
            }, 500)
    
        this.$element.one($.support.transition.end, function () {
          clearTimeout(timeout)
          that.hideModal()
        })
      }
    
    , hideModal: function (that) {
        this.$element
          .hide()
          .trigger('hidden')
    
        this.backdrop()
      }
    
    , removeBackdrop: function () {
        this.$backdrop.remove()
        this.$backdrop = null
      }
    
    , backdrop: function (callback) {
        var that = this
          , animate = this.$element.hasClass('fade') ? 'fade' : ''
    
        if (this.isShown && this.options.backdrop) {
          var doAnimate = $.support.transition && animate
    
          this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
            .appendTo(document.body)
    
          this.$backdrop.click(
            this.options.backdrop == 'static' ?
              $.proxy(this.$element[0].focus, this.$element[0])
            : $.proxy(this.hide, this)
          )
    
          if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
    
          this.$backdrop.addClass('in')
    
          doAnimate ?
            this.$backdrop.one($.support.transition.end, callback) :
            callback()
    
        } else if (!this.isShown && this.$backdrop) {
          this.$backdrop.removeClass('in')
    
          $.support.transition && this.$element.hasClass('fade')?
            this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
            this.removeBackdrop()
    
        } else if (callback) {
          callback()
        }
      }
    }

  • #4
    Junsee
    Guest
    have you tried using double quotes?

  • #5
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,237
    Thanks
    51
    Thanked 100 Times in 99 Posts
    Hmm.. Try this

    PHP Code:
    echo "<a href=\"?ip_address=".$ip_address."#accSettings1\" role=\"button\" class=\"btn btn-small btn-primary hidden-tablet hidden-phone\" data-toggle=\"modal\">Add</a>"
    or else turn on error reporting and post the error.
    Been a sign maker for 7 years. My business:
    American Made Signs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •