gpt4 book ai didi

javascript - 如何获取下一页中选定的图像?

转载 作者:行者123 更新时间:2023-12-03 01:39:04 24 4
gpt4 key购买 nike

我有下拉选项来获取图像,选择选项后图像就会显示。我想在下一页中获得相同的图像。我怎样才能实现这一目标?

index.php

    <div class="col-md-2" style="color: #000; font-family:Titillium Web">
<span style="color: #fff"> Pickup Location * </span>
<select class='selectpicker1' id='colorselector' name='pickup_loc'>
<option value=''></option>
<option value='Building1'>Building1</option>
<option value='Building2'>Building2</option>
</select>
</div>
<div class="col-md-2 text-center">
<br> <input type="text" id="pwr1" class="required p-control" name="pickup_ward" />
</div>

<div class="col-md-2" style="color: #000; font-family:Titillium Web ">
<span style="color: #fff"> Drop Location *</span>
<select class='selectpicker2' id='dropselector' name='drop_loc'>
<option value=''></option>
<option value='Floor1'>Floor1</option>
<option value='Floor2'>Floor2</option>
</select>
</div>
<div class="container colorselector show-image output">
<div id="Building1" class="colors Building2">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQWb3sciAdSaUG1Up0xz9facEB2bWr_OPZG6jNzHaQKcmwDBTB2iA" style="width: 100%" class="img-responsive" />
</div>

<div id="Building2" class="colors Building2">
<img src="https://cdn.vox-cdn.com/thumbor/MJguYcgKkDes6NzbE8Y0OgdyF64=/0x0:1500x974/1200x800/filters:focal(630x367:870x607)/cdn.vox-cdn.com/uploads/chorus_image/image/56258041/2401_Third_Ave.0.jpg" style="width: 100%" class="img-responsive" />
</div>
</div>
<div class="container dropselector show-image output">
<div id="Floor1" class="colors Floor1">
<img src="https://images.mydoorsign.com/img/lg/S/1-floor-number-braille-sign-se-6089.png" style="width: 100%" class="img-responsive" />
</div>

<div id="Floor2" class="colors Floor2">
<img src="https://images.mydoorsign.com/img/lg/S/2-floor-number-braille-sign-se-6090.png" style="width: 100%" class="img-responsive" />
</div>
</div>
$('#colorselector, #dropselector').change(function() {
var select = $(this);
$('.' + select.attr("id") + ' .colors').hide();
$('#' + select.val()).show();
});

我想在下一页中获取所选的图像。

最佳答案

在 JavaScript 中,您可以使用 session 存储来实现此目的。

在第一页上使用所需的唯一键设置图像 URL。

sessionStorage.setItem("myImage", "some url");

然后在下一页上检索图像:

sessionStorage.getItem("myImage");

关于javascript - 如何获取下一页中选定的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50940967/

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