www.webdeveloper.com
Results 1 to 4 of 4

Thread: Form results into DIV

  1. #1
    Join Date
    May 2013
    Posts
    2

    Form results into DIV

    I'm sure this has been discussed many many times, but I'm stuck with no idea what to do. I've looked at using jquery to put the results of my php function into a div with no luck - been staring at it for two days now and been through countless forums.

    Code:
    <form method="post" class="ui-buttonset" id="searchform" action="../results">
    <div id="radio" class="ui-buttonset">
    <input type="radio" id="series1" name="cat1" value="6"/><label for="series1">Category 6</label>
    <input type="radio" id="series2" name="cat1" value="7"/><label for="series2">Category 7</label>
    <input type="radio" id="series3" name="cat2" value="8"/><label for="series3">Category 8</label>
    <input type="radio" id="series4" name="cat2" value="9"/><label for="series4">Category 9</label>
    <input type="submit" id="submit" name="submit" value="Show Me My Articles" />
    </div>
    </form>
    The form works perfectly, it takes me back to my results page, and displays the results of the form via my PHP function:
    Code:
    function results(){
    		echo "Radio ".$_POST["cat1"]; echo " Radio2 ".$_POST["cat2"];
    }
    if(isset($_POST['submit']))
    {
       results();
    }
    The problem is - on my results page, the text "Radio # and Radio2 # aren't displayed in the right place, they're in the upper left of the page - outside of every containing DIV. I've been through many forums on using Ajax to get it to place the output into a div, but I can't seem to get the php function to display in the right DIV. Everything besides the display is working as I need it to.

  2. #2
    Join Date
    Apr 2013
    Posts
    56
    It sounds like you are echoing out variable before your templates are processed. First rule this possible cause out. From where are you calling results function exactly?

  3. #3
    Join Date
    May 2013
    Posts
    2
    The function results() is included inside a custom.php file within my Wordpress Template. My form is calling the results function on submit and redirecting to a different page on the site just fine...I hadn't thought about the order it was processing things (makes sense now that you said something about it...thanks!). How do I pipe the variables down into the content DIV rather than them being dumped at the top of the <body> tag? I've looked at jquery and ajax and can't seem to figure out how to do it.

  4. #4
    Join Date
    Apr 2013
    Posts
    56
    It is difficult to say where the problem lies without looking at the files. If you have file structure like this (header.php, content.php, footer.php). Why can't you just call results function from content.php file? This would definately echo out your data correctly. I do not use Wordpress myself, maybe someone who is using Wordpress might provide better assistance.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles