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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:05:52+00:00 2026-05-26T02:05:52+00:00

I have the following code: private function html_Headers() { $data = ‘ <!DOCTYPE HTML>

  • 0

I have the following code:

  private function html_Headers()
    {
        $data = '
        <!DOCTYPE HTML>
        <head>
    <script type="text/javascript">
    function getOptions(chosen){
    var selbox = document.myform.selectport;
  selbox.options.length = 0;
  if (chosen == "1") {
    selbox.options[selbox.options.length] = new Option("-----------------","0");
    }


    }
    </script>

    </head>';

I’m trying to run some php mysql queries within the getOptions() JS function. I tried writing tags but it didn’t work. Does anyone see the problem here? Note that this is within a PHP class file.

  • 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-26T02:05:52+00:00Added an answer on May 26, 2026 at 2:05 am

    JavaScript is executed on the client, while PHP is interpreted on the server.
    That means: when the javascript is executed, your code is running already on the client side and PHP – Code is going to be pretty useless.

    What you can do, is calling an PHP-file with a function over an AJAX-Call and parse the result back to the client. After this, you can do anything with the returned data, but you’ll have to do it within JavaScript.

    For AJAX-Calls, I usually use jQuery, because the calls are easy and browser differences are handled already for you.

    $.ajax({
      type: "POST",         // POST or GET
      url: "query.php",     // the php-file, including your mysql query
      data: "name=John&location=Boston",  //data sent to the server (in this case as post-param)
      success: function(data){
        //function executed, when the call succeeds. variable data is the data returned from your php
      }
    });
    

    Of course, you can make AJAX-Calls without using jQuery, maybe you should have a look at quirksmode.org

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: Public Class Form1 Private Function Step1_Execute() As Boolean Return
The following code waits for data over UDP. I have a test function that
I have the following code for finding factorials: Private Shared Function Factorial(ByVal Number As
I have following code: private void ProcessQueue() { foreach (MessageQueueItem item in GetNextQueuedItem()) PerformAction(item);
I have the following code: private static void WriteStartupInfo() { Settings settings = Settings.Default;
I have the following code private Map<KEY, Object> values = new HashMap<KEY, Object>(); public
I have the following code: private static final Set<String> allowedParameters; static { Set<String> tmpSet
I have the following code: Private Sub SortWorksheet(ByVal sheet As Worksheet) Dim sStartColumn Dim
i have the following code Private Sub select_color_Click(ByVal sender As System.Object, ByVal e As
So I have the following snippet of code: private Nullable<decimal> _excessWages; public decimal ExcessWages

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.