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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:43:30+00:00 2026-05-23T02:43:30+00:00

Once again I am ‘dabbling’ in the dark art of javascript and jQuery without

  • 0

Once again I am ‘dabbling’ in the dark art of javascript and jQuery without much of a clue as to what I’m actually doing. All I know is that I managed to get my code to function by cribbing bits of other code and modifying it a bit, and after a lot of cursing, it worked…. in a fashion.

Below is a piece of my code, which correctly builds and displays a dynamic selectbox with values returned from a mysql query. When the user selects one of the items from the list, the code successfully runs a function which displays a map associated with that item.

What I ACTUALLY need it to do is also run the code to display the map for the default/top item returned by the query first, and THEN whenever a new item is selected it should run the function to display the newly selected map.

I hope the explanation has been clear enough, but feel free to chastise me if not.

Many thanks,

Rob.

 $(document).ready(function() {
$('#selecthere').load('/temp/php_script.php?r='+ random, function () 
 { //callback
$('select', this).change(function () { //catch onchange event of select
//call your function here, pass the selected value
initialize($(this).val());
});
});
});
  • 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-23T02:43:31+00:00Added an answer on May 23, 2026 at 2:43 am

    (Edited in light of comments below.)

    If I understand, initialize(val) is the function that draws the map associated with val, and you want to run it when the page loads with val being whatever is in the select box by default. To do this, you could just add the function call in your ready function as such:

    $(document).ready(function(){
        var random = Math.random();
        // load contents of php script into #selecthere element
        $('#selecthere').load('/temp/php_script.php?r='+ random, function (){ 
           // the contents of the php script are now loaded
           // go ahead and call initialize() on the value that is selected by default
           initialize($('select[name=title]').val());
           // attach a function to fire when select element is changed
           $('select[name=title]').change(function () { 
               // here 'this' refers to the select element
               // call initialize() with the value of select element
               initialize($(this).val());
           });
        });
    });
    

    Hope I understood.

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

Sidebar

Related Questions

Once again I have written some Javascript using jQuery, and it works in every
Once again one of those: Is there an easier built-in way of doing things
Once again I'm doing Java graphics (Graphics2D) but I noticed there is no Polygon.Double
Once again, I need some help and I appreciate you all for being here
I am once again stuck with a jQuery issue, and I'm hoping for some
Once again I need some much appreciated help from the experts :) I am
Having once again been bitten by SQL Server not updating all views properly when
Once again I found JavaScript code on the Internet that contains an inline function
Once again having problems being a new to javascript. I want to get the
Once again a very beginner-ish question, but here I go: I would like 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.