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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:44:24+00:00 2026-06-13T19:44:24+00:00

I have this select object: <select id=alunos onchange=arteAluno(this);> <option selected=selected></option> <option value=loadImage();>Aluno 1</option> <option

  • 0

I have this select object:

<select id="alunos" onchange="arteAluno(this);">
    <option selected="selected"></option>
    <option value="loadImage();">Aluno 1</option>
    <option value="../Index.html">Aluno 2</option>  
    <option value="../Index.html">Aluno 3</option>
</select>

and this function:

function arteAluno (sel) {
    var url = sel[sel.selectedIndex].value;
    window.location = url;
}

and I was making the page change with this. But now I want to get this code:

$(document).ready(function() {

    function O(obj) {
        return document.getElementById(obj);
    }
    function loadImage() {
        O('arte').style.backgroundImage="url(aikido.jpg)";
        O('arte').style.width = '200px';
        O('arte').style.height = '160px';
    }
})

and make this function loadImage only be triggered when I select one of the options of the tag.

  • 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-13T19:44:25+00:00Added an answer on June 13, 2026 at 7:44 pm

    Since you are already using jQuery, you might just as well use it for everything here. You only need to bind one .change() handler which sets window.location if one of the URLs is chosen, and executes the loadImage() function otherwise.

    Rather than call the function name loadImage() in the <option> value (which looks strange), I have replaced it below with a special value value='load_image'. The .change() handler will look for that value and execute the function if found.

    <select id="alunos">
       <option selected="selected"></option>
       <!-- Special value rather than function name here -->
       <option value="load_image">Aluno 1</option>
       <!-- URL values -->
       <option value="../Index.html">Aluno 2</option>  
       <option value="../Index.html">Aluno 3</option>
    </select>
    

    And the jQuery:

    $(document).ready(function() {
      // Bind the onchange event for select#alunos
      $('#alunos').change(function() {
        // If the load_image option was selected, call the loadImage() function
        if ($(this).val() == 'load_image') {
          loadImage();
        }
        // Otherwise, load the URL
        else {
         // Unless the blank option is selected...
         if ($(this).val() !== '') {
           window.location = $(this).val();
         }
        }
      });
    });
    // Can replace with all jQuery (since you are using it anyway)
    function loadImage(){
      $('#arte').css('backgroundImage', 'url(aikido.jpg)');
      $('#arte').css('width', '200px');
      $('#arte').css('height', '160px');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have this select: <select id=days> <option value=0>Today</option> <option value=1>Yesterday</option> <option value=7>Last week</option>
I Have this XML File <?xml version=1.0 standalone=yes?> <Root> <Object> <referenceName>People</referenceName> <query>select * from
I have this object function paymentPlan(name, price, days, active){ this.name=name; this.price=price; this.days=days; this.active=active; }
I have this in models_name : model_names = Object.constants.collect { |sym| Object.const_get(sym) }.select {
I have this select input with simple_form: <%= f.input :board, :collection => Board.where(:user_id =>
i have this SELECT COUNT(1) cnt, a.auther_id FROM `posts` a LEFT JOIN users u
I have this select input in my form that I want to access via
I have this select insert into test(t_name) (select users.first_name || '_' || users.last_name ||
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
i have this query: SELECT `completed`.`ID` AS `ID`,`completed`.`level` AS `level`,`completed`.`completed_in` AS `completed_in`, COUNT(1) AS

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.