Connecting Tech Pros Worldwide Help | Site Map

how to stop user not click combo box untill value comes in combo box

Familiar Sight
 
Join Date: Nov 2007
Posts: 235
#1: Aug 31 '09
Hi

I am creating a website to find car of different make and model.for that i am using two combo box one for car make and other for car model. when user clicks car make combo box and selects say audi then its all model should come in car model combo box which is coming and for that i have used ajax. since it takes one or two second to come record in car model combo box so what i want that during that time user should not able to click that car model combo box.

actually i wanted to do in this way here is url for the link:www.buyacar.co.uk.
the same thing is happening under buy your ideal new car online section

how can i do this.
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,126
#2: Aug 31 '09

re: how to stop user not click combo box untill value comes in combo box


you may create a transparent div with a zindex that 'overlays' your div in question. therefor you just need to retrieve the coordinates of the node you wnat to overlay and set the position of the overlaying div ... in case you already use any JavaScript framework there should be methods to make that quite easy ... otherwise we could create some code here together :)

kind regards
Familiar Sight
 
Join Date: Nov 2007
Posts: 235
#3: Sep 4 '09

re: how to stop user not click combo box untill value comes in combo box


Thanks gits!
I am not using any JavaScript framework and when that transparent div will be called. If you can give some example code to understand me better or any reference url where I can find it.
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,126
#4: Sep 16 '09

re: how to stop user not click combo box untill value comes in combo box


here is a quickly hacked, quite short and FF-tested version:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. function maskItem(id) {
  6.     var node   = document.getElementById(id);
  7.     var coords = getCoords(node);
  8.  
  9.     var mask = document.createElement('div');
  10.  
  11.     mask.style.backgroundColor = 'red';
  12.     mask.style.opacity         = '0.5';
  13.     mask.style.position        = 'fixed';
  14.  
  15.     for (var i in coords) {
  16.         mask.style[i] = coords[i] + 'px';
  17.     }
  18.  
  19.     node.parentNode.appendChild(mask);
  20. }
  21.  
  22. function getCoords(node) {
  23.     var coords = {
  24.         top   : node.offsetTop,
  25.         left  : node.offsetLeft,
  26.         height: node.offsetHeight,
  27.         width : node.offsetWidth
  28.     };
  29.  
  30.     return coords;
  31. }
  32.  
  33. </script>
  34. </head>
  35. <body>
  36.     <input type="text" id="myInput" value="foo"/>
  37.     <input type="button" onclick="maskItem('myInput');" value="mask item"/>
  38. </body>
  39. </html>
  40.  
the getCoords() method might need to be extended to retrieve the correct position and measures in IE, you might have a further look here ... even the mask's css could be adapted with using a transparent image with a progress indicator or whatever ... :)

kind regards
Reply


Similar JavaScript / Ajax / DHTML bytes