473,326 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problem with onclick Event for options in IE

118 100+
Hi,


i am getting the problem when i used the onclick event in option tag.It is working fine in mozilla .But it is not working IE. Here is my code


Expand|Select|Wrap|Line Numbers
  1.  
  2. <script>
  3.  
  4. function appendRow(unit)
  5. {
  6.     var flag = true;
  7.     var arr = document.getElementById("selectedOptons").value.split(",");
  8.     //alert(arr[0]);
  9.     for(i=0; i< arr.length; i++) {
  10.         if(arr[i] == unit)
  11.             flag = false;
  12.     }
  13.     if((unit != 0) && (flag == true)) {
  14.         //alert(document.getElementById("selectedOptons").value+"," +unit);
  15.     document.getElementById("selectedOptons").value = document.getElementById("selectedOptons").value+"," +unit;
  16.     document.getElementById("defRightContent").style.display = "none";
  17.     document.getElementById("divRightContent").style.display = "block";
  18.     document.getElementById("defLeftContent").style.display = "none";
  19.     document.getElementById("divLeftContent").style.display = "block"; 
  20.      document.getElementById("divLeftContent").innerHTML = document.getElementById("divLeftContent").innerHTML + "<br><div style='height:20px'>" + "Pickup days- "+unit+":</div>";
  21.      document.getElementById("divRightContent").innerHTML = document.getElementById("divRightContent").innerHTML + "<br><div style='height:20px'><input type=checkbox name=pick_days[] value="+unit+":1 />Mon&nbsp;<input type=checkbox name=pick_days[] value="+unit+":2  />Tues&nbsp;<input type=checkbox name=pick_days[] value="+unit+":3  />Wed&nbsp;<input type=checkbox name=pick_days[] value="+unit+":4  />Thurs&nbsp;<input type=checkbox name=pick_days[] value="+unit+":5  />Fri&nbsp;<input type=checkbox name=pick_days[] value="+unit+":6 />Sat&nbsp;<input type=checkbox name=pick_days[] value="+unit+":7  />Sun</div>";
  22.  
  23.     document.getElementById("defRightContent2").style.display = "none";
  24.     document.getElementById("divRightContent2").style.display = "block";
  25.     document.getElementById("defLeftContent2").style.display = "none";
  26.     document.getElementById("divLeftContent2").style.display = "block"; 
  27.      document.getElementById("divLeftContent2").innerHTML = document.getElementById("divLeftContent2").innerHTML + "<br><div style='height:20px'>" + "Delivery days- "+unit+":</div>";
  28.      document.getElementById("divRightContent2").innerHTML = document.getElementById("divRightContent2").innerHTML + "<br><div style='height:20px'><input type=checkbox name=deliv_days[] value="+unit+":1 />Mon&nbsp;<input type=checkbox name=deliv_days[] value="+unit+":2  />Tues&nbsp;<input type=checkbox name=deliv_days[] value="+unit+":3  />Wed&nbsp;<input type=checkbox name=deliv_days[] value="+unit+":4  />Thurs&nbsp;<input type=checkbox name=deliv_days[] value="+unit+":5  />Fri&nbsp;<input type=checkbox name=deliv_days[] value="+unit+":6  />Sat&nbsp;<input type=checkbox name=deliv_days[] value="+unit+":7  />Sun</div>";
  29.     } 
  30. }
  31.  
  32. </script>
  33.  
  34.  <tr>
  35.         <td height="40" align="right" valign="middle" class="gray12 padr borderform">Market*: </td> 
  36.         <td width="42%" align="left" valign="middle" class="gray12 borderform"> <?php //print form_dropdown('region', $region_arr, $region_value, 'class="dropdown"'); ?> 
  37.           <select name="market[]" id="market" class="dropdown" multiple="multiple">
  38.                     <option  value="" >Select Market</option>
  39.                     <?php     
  40.                     $markArr = explode(',', $row['region']);
  41.                     for($i=0; $i<count($market_arr); $i++)
  42.                     { ?>
  43.                     <option  value="<?php echo $market_arr[$i][regID]; ?>" <?php if( in_array( $market_arr[$i][regID], $markArr)) { echo 'selected=selected';} ?> onclick="appendRow(this.value);" ><?php echo $market_arr[$i][regName]; ?></option>
  44.                     <?php } ?>
  45.           </select> 
  46.           <input type="hidden" value="" name="selectedOptons" id="selectedOptons" />
  47.         </td>
  48.         <td width="30%" align="left" valign="middle" class="gray12 borderform">
  49.         <?php if($mode != "add") { ?>
  50.         <a href="addEdit_loc_distance.php?memType=2&objID=<?php echo $_REQUEST['objID']; ?>" class="green12link"> Edit Distance</a>
  51.         <?php } ?>        </td>
  52.       </tr>
  53.  
  54.  

I need to add some content when i select the item in drop down list every time.For that i modified this code as in select tag i have used the onchange event instead of onclick in option tag.But i am not getting the proper result. Any body Please help me how can i resolve my problem in IE.




Thanks
SwethaK
Jun 17 '09 #1
2 2494
acoder
16,027 Expert Mod 8TB
In IE, options are considered part of the select, not elements in their own right, at least for events. You will need to use the select onchange event, or use a button.

You mention that you've used select onchange. What changes did you make? Remember that you'll have to loop over all the options to get the selected ones.
Jun 17 '09 #2
Markus
6,050 Expert 4TB
You should be using onchange to deal with <select> elements, and if it's not working correctly, you're not doing it right.

Blah, nevermind. :D
Jun 17 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Shock | last post by:
Hello everyone, I am having a problem with the program below. I have isolated the problem to the onclick event that is located throughout arrQuestions. The onclick event refers to a function...
8
by: rdlebreton | last post by:
Hi, Folks! I've been trying to develop my own version of these draggable layers and I have been limiting myself to IE6...for now. I have looked at some other examples to get ideas of creating...
12
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
4
by: Bart van Deenen | last post by:
Hi all I have a script where I dynamically create multiple inputs and selects from a script. The inputs and selects must have an associated onchange handler. I have the script working fine on...
1
by: Steven M | last post by:
Hello!!! I dont know what is the problem!!! I am desperate!!! I want to put enabled = false a button when in ListBox has selected more than a item. this is the javascript. it dosen't...
13
by: Oliver Hauger | last post by:
Hello, In my html form I show a select-element and if this element is clicked I fill it per JavaScript/DOM with option-elements. I use the following code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD...
7
by: raknin | last post by:
Hi I have a carousel script. I want to load the carousel with a new set of pictures every time I press a button. The problem that I have that the script append the new pictures to the olds one...
3
omerbutt
by: omerbutt | last post by:
hi there i have downloaded a prototype tooltip from http://www.nickstakenburg.com/projects/prototip/ the logic it uses is to call the script after creating the <div> for example i am using the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.