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

  • Home
  • SEARCH
  • 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 8362515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:57:30+00:00 2026-06-09T11:57:30+00:00

I want to call twoJS functions on onchange event and both functions returns some

  • 0

I want to call twoJS functions on onchange event and both functions returns some value. It does not gives me the second function output:

My PHP Code:

  <select name="lstTypex" id="lstTypex" onchange="javascript:showCondition(this.value);showInputType(this.value);">
     In options some values
  </select>
  <span id="condition" style="padding-left:19px;"></span>
  <span id="inputType" style="padding-left:19px;"></span>

My Ajax Code:

// This function is used to submit for condition fields by ajax
function showCondition(colName) {

if (colName.length == 0) { 
    document.getElementById("condition").innerHTML="";
    return;
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
}
else {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
        document.getElementById("condition").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","ajax/entity_report.php?colName="+colName+"&doAction=showCondition",true);
xmlhttp.send();
}

// This function is used to submit for condition fields by ajax
function showInputType(colName) {

if (colName.length == 0) { 
    document.getElementById("inputType").innerHTML="";
    return;
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
}
else {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
        document.getElementById("inputType").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","ajax/entity_report.php?colName="+colName+"&doAction=showInputType",true);
xmlhttp.send();
} 

My PHP-Ajax Code:

// include all required files for this screen
include("../include/common.php");
include(MODEL . "entity_report_class.php");

// create class object for class function access
$objCallUsers = new Entity_Report();

// call required class file functions 
$returnStr = "";
$arrTypex = $objCallUsers->fetch_data_type();
$typex = $arrTypex[$_REQUEST['colName']];

switch($_REQUEST['doAction']) {
case 'showCondition': 
    $arrCondition = array();
    if($typex == 'TB' || $typex == 'TA') {
        $arrCondition = array("Equal to","Not equal to","Starts with","Contains any part of word","Contains full word");
    }
    else if($typex == 'DD' || $typex == 'RD') {
        $arrCondition = array("Equal to","Not equal to");
    }

    $returnStr .= '<select name="lstCondition" id="lstCondition">
    <option>--Please Select--</option>';

    foreach ($arrCondition AS $condition) {
        $returnStr .= '<option>' . $condition . '</option>';
    }

    $returnStr .= '</select>';

break;

case 'showInputType': 
$arrCondition = array();
if($typex == 'TB' || $typex == 'TA') {
     $returnStr .= '<input type="text" name="conditionValue" id="conditionValue" value="" />';
}
else if($typex == 'DD' || $typex == 'RD') {
     $returnStr .= ' <select name="conditionValue" id="conditionValue"></select>';
}

break;
}

print($returnStr);

It is giving me output as per the second function call. Both functions returns something.

  • 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-09T11:57:31+00:00Added an answer on June 9, 2026 at 11:57 am

    You are using a global variable xmlhttp and the second function overwrites it. You should make it local to both functions by introducing it with the var keyword.

    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        var xmlhttp=new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call a function printPager($max_pages,$pg); to show up after the last value
i want call 2 actions but, if return false from first event, second will
I want to call some function repeatly in client's browser. System::Timers::Timer work only on
I want to call a method which returns a value every few seconds. I
I want to call a function a number of times providing it with different
I want to call a function which is in another php class that I
I want to call a website using PL/SQL and get the return value of
I want to call the functions by their name at run time like string
I want to call a EXE file in Perl which performs some action I
I want call OnClick function on page load with out user clicking. Can we

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.