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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:12:54+00:00 2026-05-23T14:12:54+00:00

I have a page called getvalues.php, I need to call a function which is

  • 0

I have a page called getvalues.php, I need to call a function which is written in a different php page(fileclass.php) in a class from this page(getvalues.php), but the issue is i need to pass a variable also which is $i, and the value of $i passed should be 1 if we are selecting option B, and $i=2 if option=c, and $i=3 if option=D given in dropdown. I had simply wiritten an onchange event but had not written any code in javascript. Please help Thanks. Here is the code for getvalues.php

 <html>
 <select id="s" onchange="callsome();">
    <option value='B' selected>B</option>
    <option value='c'>c</option>
    <option value='D'>D</option>
 </select></html>
 <?php include("fileclass.php")
      $obj=new file;
      echo $obj->func($i);?>
  • 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-05-23T14:12:54+00:00Added an answer on May 23, 2026 at 2:12 pm

    You could implement this using JQuery or Javascript (I use JQuery in the example because it is shorter and easier to make Ajax calls) :

    <html>
       <select id="s" onchange="callsome();">
           <option value='1' selected="selected">B<option>
           <option value='2'>C</option>
           <option value='3'>D</option>
       </select>
    
       <script>
           function callsome() {
               var selected = $('select#s option:selected').val();
               $.ajax({
                   type: "POST",
                   url: "fileclass.php",
                   data: ({selectedvalue : selected}),
                   success: function(data) {
                      alert(data);
                   }
               });
           }
       </script>
    </html>
    

    After that the callsome returns the output of the fileclass.php script and you can use that however you like in your code. From your explanation it was not really clear what is happening in fileclass.php and what you want to do with it, so I hope it helps you.

    If you want the function in Javascript only:

    <script type="text/javascript">
    function callsome() {
         var e = document.getElementById("s");
         var strVal = e.options[e.selectedIndex].value;
    
         var xmlhttp;
         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) {
                   var data = xmlhttp.responseText;
                   //use the data as you wish
              }
         }
         xmlhttp.open("GET","fileclass.php?selectedvalue=strVal",true);
         xmlhttp.send();
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page called list.php which retrieves from database and shows all the
I have a page called index.php which is calling a function writelog in includes/Logger.php
I have a page called send.email.php which sends an email - pretty simple stuff
I have a page called send.email.php which sends an email - pretty simple stuff
I have this page called up.php that adds 1 to a txt file set
In my webapp I have a page called display.php. The script in this page
I have a class called IssuesView which implements INotifyPropertyChanged . This class holds an
I have a page called k.html which is in domain A. This page will
So i have a page called region.php, which in the header, loads JQuery, the
So I have html page called A.html it was called like this from B.html

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.