copying link id to an input field
Posted
by zurna
on Stack Overflow
See other posts from Stack Overflow
or by zurna
Published on 2010-03-22T14:35:54Z
Indexed on
2010/03/22
15:01 UTC
Read the original article
Hit count: 385
The code works fine when links are images. But I have a problem when there are flash movies. Another page opens with undefined in the address bar when it needs to copy the link id to imagesID input box.
<script type="text/javascript">
var $input = $("#imagesID"); // <-- your input field
$('a.thumb').click(function() {
var value = $input.val();
var id = $(this).attr('id');
if (value.match(id)) {
value = value.replace(id + ';', '');
}
else {
value += id + ';';
}
$input.val(value);
});
</script>
<ul class="thumbs">
<li>
<a class="thumb" id="62">
<img src="/FLPM/media/images/2A9L1V2X_sm.jpg" alt="Dock" id="62" class="floatLeft" />
</a>
<br />
<a href="?Process=&IMAGEID=62" class="thumb"><span class="floatLeft">DELETE</span></a>
</li>
<li>
<a class="thumb" id="61">
<img src="/FLPM/media/images/0E7Q9Z0C_sm.jpg" alt="Desert Landscape" id="61" class="floatLeft" />
</a>
<br />
<a href="?Process=&IMAGEID=61" class="thumb"><span class="floatLeft">DELETE</span></a>
</li>
<li>
<a class="thumb" id="60">
<img src="/FLPM/media/images/8R5D7M8O_sm.jpg" alt="Creek" id="60" class="floatLeft" />
</a>
<br />
<a href="?Process=&IMAGEID=60" class="thumb"><span class="floatLeft">DELETE</span></a>
</li>
<li>
<a class="thumb" id="59">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0" id="59" width="150" height="100" style="float:left; border:5px solid #CCCCCC; margin:5px 10px 10px 0;">
<param name="scale" value="exactfit">
<param name="AllowScriptAccess" value="always" />
<embed name="name" src="http://www.refinethetaste.com/FLPM/media/flashes/7P4A6K7M.swf"
quality="high" scale="exactfit" width="150" height="100"
type="application/x-shockwave-flash"
AllowScriptAccess="always"
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?
P1_Prod_Version=ShockwaveFlash">
</embed>
</object>
</a>
<br />
<a href="?Process=&IMAGEID=59" class="thumb"><span class="floatLeft">DELETE</span></a>
</li>
</ul>
© Stack Overflow or respective owner