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 7770083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:19:17+00:00 2026-06-01T16:19:17+00:00

I have php code that calls a javascript function: onclick=’fightit(0,0,0,0,0)’ Here is the javascript

  • 0

I have php code that calls a javascript function:

onclick='fightit(0,0,0,0,0)'

Here is the javascript function:

function fightit(nbr,strt,bar,type,action) {
var params = "Nbr="+nbr;
params += "&Strt="+strt;
params += "&Bar="+bar;
params += "&FightType="+type;
params += "&Action="+action;
alert(params);
new Ajax.Updater('div01', 'php/fight.php', {method: 'get', parameters: params, onComplete: div05F});
}

When I call the function and display params I get;

Nbr=1&Strt=0&Bar=0&FightType=0&Action=0

This is what I’m suppose to get but when I use it in my php:

if (!isset($_GET['Action'])) {
    $_GET['Action'] = 0;
}
if (isset($_GET['FightType'])) {
   $fighttype = $_GET['FightType'];
}
else {
   $fighttype = 0; 
}
$s = $_GET['FightType'];

Action is set but FightType is not when I execute this line of code:

$s = $_GET['FightType'];

I get:

Undefined index: FightType in C:\wamp\www\hand\php\div08F.php on line 10

Any ideas where I’m going wrong?

  • 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-01T16:19:18+00:00Added an answer on June 1, 2026 at 4:19 pm

    EDIT2: OK, with that information, I tested out. I think you are using one file, so I set up a mock php file to test things. I removed the onComplete and set a div with the update. Here is the result that works. Let me know if it helps:

    <?php
    if ( isset($_GET['Nbr']) ){
        // here Nbr is set, so we drop into outputting xml... you can do more before this
        // and you can open a separate file, but didn't know how things were set up for you.
        header('Content-Type: text/xml');
        $out = $_GET['Nbr'].','
            .(isset($_GET['Strt'])?$_GET['Strt']:'').','
            .(isset($_GET['Bar'])?$_GET['Bar']:'').','
            .(isset($_GET['FightType'])?$_GET['FightType']:'').','
            .(isset($_GET['Action'])?$_GET['Action']:'');
        print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'><span>'.htmlentities($out).'</span>';
        exit();
    }
    ?>
    <html>
    <head>
    <script type="text/javascript" src="prototype.js"></script>
    <script type="text/javascript">
    function fightit(nbr,strt,bar,type,action) {
        var params = "Nbr=" + nbr
            + "&Strt=" + strt
            + "&Bar=" + bar
            + "&FightType=" + type
            + "&Action=" + action;
        alert(params);
    
        // this is actually calling itself with '/t.php' and updating div01
        new Ajax.Updater('div01', '/t.php', {method: 'get', parameters: params});
    }
    
    </script>
    </head>
    <body>
    <table style="border-style:none;">
        <tr>
            <td style="border-style:none;">
                <input style="width:150px; text-align:center;" type="button" value="Steal" onclick="stealit()" />
            </td>
            <td id="fightBtn" style="border-style:none;"><input style="width:150px; text-align:center;" type="button" value="Fight" onclick="fightit(0,0,0,0,0)" />
            </td>
        </tr>
        <div id="div01"></div>
    </body>
    </html>
    

    ORIGINAL:

    You are getting the fighttype error, because even though you check for it, you still use it after the check without rechecking ($_GET['FightType'] still doesn’t exist). Try this:

    if (isset($_GET['FightType'])) {
       $fighttype = $_GET['FightType'];
    }
    else {
       $fighttype = 0; 
    }
    $s = $fighttype;
    

    EDIT: to fix the ajax, try parameters like this (you might have to change the function variable names):

    new Ajax.Updater('div01', 'php/fight.php', {method: 'get', parameters: {Nbr: nbr, Strt: strt, Bar: bar, FightType: type, Action: action}, onComplete: div05F})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a php code which by echo calls the javascript function expand(txt)
I have a legacy PHP/MySQL app that calls mysql_connect(). Tons of existing downstream code
So I have some PHP code that looks like: $message = 'Here is the
I have the following code in page1.php : <a href=page2.php onClick=javascript:callFlash();>Go to page</a> This
I have the following function in javascript that calls the ajax which calls the
I have a page, test.php, with the following code: <html> <body> <form> <script type=text/javascript>
here is my js code <script type='text/javascript'> // Browser safe opacity handling function function
I have some PHP code that generates dynamic tables of data on the fly.
I have some PHP code that is designed to make a spreadsheet with formulas
I have some PHP code that generates a calendar and then outputs html to

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.