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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:28:06+00:00 2026-05-25T19:28:06+00:00

I have a JS/PHP piece of code that selects from a database, does some

  • 0

I have a JS/PHP piece of code that selects from a database, does some things with the ID’s of the tables and outputs the data in a dropdown.

My JS currently appends myfile.php?cat=X&projectID=Y correctly and i’m grabbing the variables correctly, but when I select the second dropdown it doesn’t output the name, it only appends the ID to the title and variable..

     function reload(form)
    {
    var val=form.cat.options[form.cat.options.selectedIndex].value;
    var val2=form.cat2.options[form.cat2.options.selectedIndex].value;
    self.location='add-recharge.php?cat=' + val + '&projectID=' + val2;
    }

The PHP

<?

            @$cat=$_GET['cat'];
            if(strlen($cat) > 0 and !is_numeric($cat)){  
            echo "Data Error";
            exit;
            }

            //MYSQL stuff


            echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select a client</option>";

                while($noticia2 = mysql_fetch_array($quer2)) { 
                 if($noticia2['clientID']==@$cat){echo "<option selected value='$noticia2[clientID]'>$noticia2[clientName]</option>"."<BR>";}
                    else{echo  "<option value='$noticia2[clientID]'>$noticia2[clientName]</option>";}
                }
                echo "</select>";
                echo "&nbsp;<span class='req'><img src='/images/essentialInput.png' alt='*' title='*' border='0' /></span>";
                echo "&nbsp; &nbsp;<span class='label'>Project</span>" . "&nbsp;";
                echo "<select name='cat2' onchange=\"reload(this.form)\"><option value=''>Select a project</option>";

                while($noticia = mysql_fetch_array($quer)) { 
                    echo  "<option value='$noticia[projectID]'>$noticia[projectName]</option>";
                }
                 echo "</select>";
                 echo $intClientID;
                 //echo "<br /><br /><br /><br />";   
       ?>

How do I get it to update it with projectName and not reload with ‘Select project’ ?

  • 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-25T19:28:07+00:00Added an answer on May 25, 2026 at 7:28 pm

    Try using:

    var val=form.cat.value;

    var val2=form.cat2.value;

    EDIT

    Apologies, I misunderstood the question.

    You need some form of if/else logic in your PHP similar to that used on the Client select, but dependent on the projectID. Something like:

    if( $_GET['projectID'] == $noticia[projectID] ){
        echo "<option selected value='$noticia[projectID]'>$noticia[projectName]</option>";
    } else {
        echo "<option value='$noticia[projectID]'>$noticia[projectName]</option>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of php code that reads values from a database resultset,
I have the following piece of code taken from the PHP manual on the
I have a piece of code that fetches data by giving it an ID.
I have a php file that receives data from mySQL table. The mySQL table
I have a piece of code that returns product data including a price. However
Currently I have a small piece of PHP code that gets one random row
I have a div that has inside a piece of php code I need
I have a php code that generates a piece of html code like this.
I have a PHP page that returns a piece of HTML to set the
I have php scripts that do things like register, login, upload. I would like

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.