gpt4 book ai didi

javascript - Jquery onclick图像id形成输入字段

转载 作者:行者123 更新时间:2023-12-02 19:22:53 26 4
gpt4 key购买 nike

我有一个动态表单...它有一个输入字段,类似于

<form class=""
<input name="image_0" .. />
<input name="image_1" .. />
<input name="image_4" .. />
<input name="image_6" .. />
<input name="image_7" .. />
....
</form>

我还有另一个 ul li block ,它从 Facebook 相册获取图像...当我们单击图像时,它的“id”必须填写任何输入字段的空白,并且不能重复选择...

图片:Check this image may be it helps to understand

编辑:

<form class="fb_upload_id" method="get">
image_2:<input name="image_2" type="text">
image_3:<input name="image_3" type="text">
image_4:<input name="image_4" type="text">
</form>

<ul class="facebook_album_photo_list">
<li alt="Paradise Vision from http://Stockwallpapers.in" title="Paradise Vision from http://Stockwallpapers.in" id="463526207001195">
<a style="background: url(https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/427440_463526207001195_392636722_s.jpg) center top no-repeat;" class="overlay_photo" href="javascript:void(0);" onclick="add_image_fb('463526207001195');"></a>
</li>
<li alt="Anonymous Mask from http://Stockwallpapers.in" title="Anonymous Mask from http://Stockwallpapers.in" id="463151140372035">
<a style="background: url(https://fbcdn-photos-a.akamaihd.net/hphotos-ak-snc6/10476_463151140372035_468769127_s.jpg) center top no-repeat;" class="overlay_photo" href="javascript:void(0);" onclick="add_image_fb('463151140372035');"></a>
</li>
<li alt="Mirana Nightshade Priestess of the Moon from http://Stockwallpapers.in" title="Mirana Nightshade Priestess of the Moon from http://Stockwallpapers.in" id="463137303706752">
<a style="background: url(https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/482085_463137303706752_723444526_s.jpg) center top no-repeat;" class="overlay_photo" href="javascript:void(0);" onclick="add_image_fb('463137303706752');"></a>
</li>
<li alt="Fluid Flow in Lauterbrunnen from http://Stockwallpapers.in" title="Fluid Flow in Lauterbrunnen from http://Stockwallpapers.in" id="459694870717662">
<a style="background: url(https://fbcdn-photos-a.akamaihd.net/hphotos-ak-snc7/312978_459694870717662_1068867909_s.jpg) center top no-repeat;" class="overlay_photo" href="javascript:void(0);" onclick="add_image_fb('459694870717662');"></a>
</li>
</ul>

最佳答案

由于 onclick 事件处理程序已绑定(bind)到 add_image_fb,因此只需添加以下内容:

function add_image_fb(id) {
$('.fb_upload_id input:text[value=""]').first().val(id);
}

更新:

function add_image_fb(id) {
var inputs=$(".fb_upload_id input:text[value='']");
if(!inputs.length) alert('All input fields filled up!');
else inputs.first().val(id);
}

Demo .

关于javascript - Jquery onclick图像id形成输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12336301/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com