I have problem with this function, I use this http://rvera.github.io/image-picker/ and I want to create option for user to forward to proper website after choosing appropriate image. Forwarding is working but images dissappears with this code. Any ideas?
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="css.css">
<script src="js.js"></script>
<!-- scripts for imagepicker -->
<link rel="stylesheet" href="image-picker.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="image-picker.js"></script>
<script type="text/javascript" src="image-picker.min.js"></script>
<script type="text/javascript">
"use strict";
//wait for the page to be fully loaded
window.onload = function() {
initialize();
}
</script>
</head>
<body>
<!--code for imagepicker-->
<select multiple="multiple" class="image-picker show-html" id="selectImg">
<option data-img-src="http://placekitten.com/220/200" value="http://cats.com">Cute Kitten 1</option>
<option data-img-src="http://placekitten.com/180/200" value="http://dogs.com">Cute Kitten 2</option>
<option data-img-src="http://placekitten.com/130/200" value="http://dogsandcats.com">Cute Kitten 3</option>
</select>
<button href="#" id="forwardButton">Forward</button>
<script>
function initialize() {
var choice = document.getElementById("selectImg").value;
//changes destination when you set or change your choice
document.getElementById("selectImg").onchange = function() {
choice = document.getElementById("selectImg").value;
}
//when button is clicked
document.getElementById("forwardButton").onclick = function() {
if (choice !== ("" || "undefined")) {
window.location = choice;
}
}
}
</script>
</body>
</html>
I think you haven't initialized image picker.
from http://rvera.github.io/image-picker/
Then just call imagepicker on the target elements. $("select").imagepicker()
Why do you load image-picker.js and the same file in minified version?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.