Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8540315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:34:10+00:00 2026-06-11T11:34:10+00:00

—————————PHP CODE—————————: <?php $wtype = $_POST[‘wtype’]; $attributes = array(); if($wtype == ‘Ninja’){ $attributes[‘health’] =

  • 0

—————————PHP CODE—————————:

    <?php

$wtype = $_POST['wtype'];

$attributes = array();

if($wtype == 'Ninja'){
    $attributes['health'] = '40-60';
    $attributes['attack'] = '60-70';
    $attributes['defense'] = '20-30';
    $attributes['speed'] = '90-100';
    $attributes['evade'] = '0.3-0.5';
}
else if($wtype == 'Samurai'){
    $attributes['health'] = '60-100';
    $attributes['attack'] = '75-80';
    $attributes['defense'] = '35-40';
    $attributes['speed'] = '60-80';
    $attributes['evade'] = '0.3-0.4';
}
else if($wtype == 'Brawler'){
    $attributes['health'] = '90-100';
    $attributes['attack'] = '65-75';
    $attributes['defense'] = '40-50';
    $attributes['speed'] = '40-65';
    $attributes['evade'] = '0.3-0.35';
}

echo json_encode($attributes);

?>

—————————HMTL CODE—————————:

 <div id="warriors">
        <form id="blue_team">
            <p>
                <label class="team">Blue Team</label>
            </p>
            <p>
                <a href="#Naruto"><img class="blue_img" src="resources/naruto.png" title="Ninja" alt="Naruto"></a>
                <a href="#Sasuke"><img class="blue_img" src="resources/sasuke.png" title="Samurai" alt="Sasuke"></a>
                <a href="#Sakura"><img class="blue_img" src="resources/sakura.png" title="Brawler" alt="Sakura"></a>
            </p>
            <p>
                <label>Name:</label>
                    <input id="blue_name" type="text" readonly="readonly">
                <label>Type:</label>
                    <input id="blue_type" type="text" readonly="readonly">
            </p>
        </form>

    <!--Blue Dialog-->
    <div title="Warrior Name - Blue" id="blue_form" class="blue_dialog">
        <form>
            <p>
                <label>Name:</label>
                    <input id="name" type="text">
            </p>
        </form>
        <table>

        <table>
    </div>

—————————JS CODE—————————:

<script>
    $(function() {
        $("button").button();
        $(".blue_img").click(function() {
            var blue_type = $(this).attr("title").trim();
            $.ajax({
                url: "get_attributes.php",
                type: "post",
                datatype: "json",
                data: {wtype: blue_type },
                success: function(data) {
                    var toAppend = '';
                    if(typeof data === "object"){
                        for(var i=0;i<data.length;i++){
                            var attributes = data[i];
                            toAppend += "<tr><td>"+data[i]['health']+"</td></tr>";
                            toAppend += "<tr><td>"+data[i]['attack']+"</td></tr>";
                            toAppend += "<tr><td>"+data[i]['defense']+"</td></tr>";
                            toAppend += "<tr><td>"+data[i]['speed']+"</td></tr>";
                            toAppend += "<tr><td>"+data[i]['evade']+"</td></tr>";
                        }
                        $("#blue_form table").append(toAppend);
                    }
                }
            });
            $("#blue_form #name").val($(this).attr("alt").trim());
            $("#blue_form").dialog({
                    width:250,
                    resizable:false,
                    modal:true,
                    buttons: {
                        "Done": function() {
                            $("#blue_name").val($("#blue_form #name").val().trim());
                            $("#blue_type").val(blue_type);
                            $("#blue_form").hide(400);
                            $(this).dialog("close");
                        }
                    }
            });
        });
    });
</script>

Please I am expecting an table of data output to #blue_form but I didn’t get any. But my other functions works well. But when I see the javascript console it identifies the method post

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:34:11+00:00Added an answer on June 11, 2026 at 11:34 am

    From your code I’m not sure why you need a loop, you could just do something like

    success: function(data) {
        var toAppend = '';
        if(typeof data === "object") {
            toAppend += "<tr><td>"+data['health']+"</td></tr>";
            toAppend += "<tr><td>"+data['attack']+"</td></tr>";
            toAppend += "<tr><td>"+data['defense']+"</td></tr>";
            toAppend += "<tr><td>"+data['speed']+"</td></tr>";
            toAppend += "<tr><td>"+data['evade']+"</td></tr>";
            $("#blue_form table").append(toAppend);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So to start, I have an array of XML files. These files need to
I'm creating a FORM with PHP for an intranet webpage. Another PHP script is
All of my code is on my SVN, but I want some of it
I have set of xml elements like this: <item code=<HTML_CODE> /> For example: <items>
&mdash; or &#8212; Is there a difference between these? Is one better-supported than the
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm using a DatePicker ( org.apache.wicket.extensions.yui.calendar.DatePicker — Javadoc ) in a form. The form
I'm trying to get random numbers between 0 and 100. But I want them
string formIdList = 8256, 8258, 8362, 8120, 8270, 8271, 8272, 8273, 8257, 8279, 8212,
I am using JSoup to parse a gb2312 charset page: http://vars.sinaapp.com/u/t/jsoup_output_encoding_issue.html source code: String

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.