After some struggle, I got the following code for my problem. However, it still does not add the highlighted selected option. You can find my original question below. The code has been improved, but it still does not work.
var $index = $('.drop').index(this)
var $indexofmonth = $index + 1;
var $indeximg = event.dragTarget.title;
var $indeximgnum = $indeximg.replace(/[a-zA-Z]/g,"");
var $featurenumber = "Feature" + $indexofmonth;
var $eqnum = 'option:eq('+$indeximgnum + ')';
$sel = $("select[name='"+ $featurenumber +"']");
$('$sel $eqnum').attr('selected', 'selected' );
+++++++++++++++++++++++++++++++
This is my original question.
I have the following HTML and jQuery. HTML is the result of CMS.
I used drag and drop from http://threedubmedia.com/demo/drop/ because they are full 6k. The core of jQuery UI itself is larger than 100k.
I want to delete one image per month. there are over 20 images and of course there are twelve months. For this, I used drag and drop.
I used only four images and four months for my demo purpose.
, . , , .
, , .
, , , 100% .
: FeatureValue , januar - FeatureValue1
1: 1,2,3.. / var monthindex
2: var FeatureValue var featurenumber
3: tis FeatureValue ( ) ,
4: var = dropimg
5: add: , dropimg = img, dropimg
. .
HTML
<div id="calendarimg">
<div id="status"></div>
<div id="calendartable">
<div id="jan" class="drop" Title="januar" > </div>
<div id="feb" class="drop" Title="febrar" > </div>
<div id="mar" class="drop" Title="mars" > </div>
<div id="apr" class="drop" Title="april"> </div>
<div id="mai" class="drop" Title="mai"> </div>
<div id="jun" class="drop" Title="juni"> </div>
<div id="jul" class="drop" Title="juli"> </div>
<div id="aug" class="drop" Title="august"> </div>
<div id="sep" class="drop" Title="september"> </div>
<div id="oct" class="drop" Title="october"> </div>
<div id="nov" class="drop" Title="november"> </div>
<div id="dec" class="drop" Title="december"> </div>
</div>
<div id="nodrop">
<div class="drag" title="Angel" id="angel1"></div>
<div class="drag" title="Dolphin" id="dolphin2"></div>
<div class="drag" title="Fantail" id="fantail3"></div>
<div class="drag" title="Hawk" id="hawk4"></div>
</div>
</div>
<div id="featureright2">
<form method="post" action="http://www.mywebsite.com/shopaddtocart.asp">
<table cellspacing="1" cellpadding="2" border="0"><tr><td class="al">
<p class="al"><strong>januar</strong></p>
<select size="3" name="FeatureValue1">
<option value="" selected="selected">velg</option>
<option value="97">Angel</option>
<option value="98">Dolphin</option>
<option value="99">Fantail</option>
<option value="89">Hawk</option>
</select>
<input type="hidden" name="Feature1" value="88">
<p class="al"><strong>februar</strong></p>
<select size="3" name="FeatureValue2">
<option value="" selected="selected">velg</option>
<option value="109">Angel</option>
<option value="110">Dolphin</option>
<option value="111">Fantail</option>
<option value="101">Hawk</option>
</select>
<input type="hidden" name="Feature2" value="100">
<p class="al"><strong>mars</strong></p>
<select size="3" name="FeatureValue3">
<option value="" selected="selected">velg</option>
<option value="112">Angel</option>
<option value="121">Dolphin</option>
<option value="122">Fantail</option>
<option value="123">Hawk</option>
</select>
<input type="hidden" name="Feature3" value="120">
<p class="al"><strong>april</strong></p>
<select size="3" name="FeatureValue4">
<option value="" selected="selected">velg</option>
<option value="124">Angel</option>
<option value="133">Dolphin</option>
<option value="134">Fantail</option>
<option value="135">Hawk</option>
</select>
<input type="hidden" name="Feature4" value="132">
</td></tr><tr><td class="ac">
<input class="txtfield" type="text" size="2" maxlength="3" name="quantity" value="1" />
</td><td class="ac vm"><input class="imgbtn" src="images/vpnav_buy_norw.gif" type="image"></td></tr>
<input type="hidden" name="productid" value="81" />
</table></form>
</div>
JQuery
$(".drag")
.bind( "dragstart", function( event ){
var $drag = $( this ), $proxy = $drag.clone();
$drag.addClass("outline");
return $proxy.appendTo( document.body ).addClass("ghost");
})
.bind( "drag", function( event ){
$( event.dragProxy ).css({
left: event.offsetX,
top: event.offsetY
});
})
.bind( "dragend", function( event ){
$( event.dragProxy ).fadeOut( "normal", function(){
$( this ).remove();
});
if ( !event.dropTarget && $(this).parent().is(".drop") ){
$('#status').empty().append('<div>Removed <b>'+ this.title +'</b> from <b>'+ this.parentNode.title +'</b></div>');
$('#nodrop').append( this );
}
$( this ).removeClass("outline");
});
$(".drop")
.bind( "dropstart", function( event ){
if ( this == event.dragTarget.parentNode ) return false;
$( this ).addClass("active");
})
.bind( "drop", function( event ){
$( this ).append( event.dragTarget );
$('#status').empty().append('<div>Dropped <b>'+ event.dragTarget.title +'</b> into <b>'+ this.title +'</b></div>');
})
.bind( "dropend", function( event ){
$( this ).removeClass("active");
});