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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:43:13+00:00 2026-06-01T22:43:13+00:00

My code var row2 =<?php echo json_encode($_SESSION[‘row2’]) ?>; for (var i = 0; i

  • 0

My code

var row2 =<?php echo json_encode($_SESSION['row2']) ?>;
for (var i = 0; i < row2.length; i++) {
   if(row2[i][0] == x) {
      var select = document.getElementById("mTask");
      select.options[select.options.length] = new Option(row2[i][2], row2[i][1]);
   }
}

and it generates this in html

<select id="mTask" size="12">
  <option value="0">Rätt eller fel!</option>
  <option value="1">A Valles Verktygsaffär</option>
  <option value="2">A Stina för dagbok</option>
  <option value="3">A Dagbok för cykelverkstad</option>
  <option value="4">A Dagbok för elfirma</option>
  <option value="5">A Dagbok för innebandyklubb</option>
</select>

I would like the looks like this, is it possible?

<option ondblclick="mainLink(270)">Rätt eller fel!</option>
  • 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-01T22:43:15+00:00Added an answer on June 1, 2026 at 10:43 pm

    You can pass this into the function which will reference the selected option. I only added it for the second choice.

    Here is a better solution. Bind a single function to the select list and then use the data-attribute to store the 270 number.

    http://jsfiddle.net/sUqVV/1/

    <select id="mTask" size="12" ondblclick="mainLink2(this);">
        <option data-id="270" value="0">Rätt eller fel!</option>
        <option data-id="271" value="1">A Valles Verktygsaffär</option>
        <option data-id="272" value="2">A Stina för dagbok</option>
        <option data-id="273" value="3">A Dagbok för cykelverkstad</option>
        <option data-id="274" value="4">A Dagbok för elfirma</option>
        <option data-id="275" value="5">A Dagbok för innebandyklubb</option>
    </select>
    <script>
        function mainLink2(select) {
            var selectedValue = select.options[select.selectedIndex].value;
            var dataAttrib = select.options[select.selectedIndex].getAttribute('data-id');
            alert( selectedValue + ':' + dataAttrib);
        }
    </script>
    ​
    

    OLD
    http://jsfiddle.net/sUqVV/

    <select id="mTask" size="12" ondblclick="mainLink2(this);">
        <option value="0">Rätt eller fel!</option>
        <option ondblclick="mainLink(270, this);" value="1">A Valles Verktygsaffär</option>
        <option value="2">A Stina för dagbok</option>
        <option value="3">A Dagbok för cykelverkstad</option>
        <option value="4">A Dagbok för elfirma</option>
        <option value="5">A Dagbok för innebandyklubb</option>
    </select>
    <script>
        function mainLink(id, option) {
            alert(id + ':' + option.value);
        }
    </script>
    

    ​

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

Sidebar

Related Questions

Code: var result = db.rows.Take(30).ToList().Select(a => AMethod(a)); db.rows.Take(30) is Linq-To-SQL I am using ToList()
My code: var parent = document.createElement('div'); var pen = document.createElement('div'); var dog = document.createElement('div');
my code: var req = new XMLHttpRequest(); req.open(GET,http://http://surfkid.redio.de/link.php); req.send(null); var textout = var.responseText; document.write(textout);
I have the following code: var images = document.getElementsByTagName('img'); if (screen.width > 640) {
I have this code: var $msg = jQuery('<div></div>') .hide() .appendTo(document.body) ; if ($msg.is(:hidden)) {
My code: var array1 = document.getElementsByClassName(div); var array2 = document.getElementsByClassName(button); for(var i = 0;
See code: var file1 = 50.xsl; var file2 = 30.doc; getFileExtension(file1); //returns xsl getFileExtension(file2);
The code: var foo = /\</; When I go to jslint.com and enter that
This code var offset = $('#snapwrap_inner').offset(); alert(offset.left) in FF returns 0px but in Opera
When executing the code: var cont:Sprite = new Sprite(); var a:Vector.<int > = Vector.<int

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.