私は次のことを行うJS/JQueryの方法を探しています1:一連のペイントチップを「なし」の画像と一緒に並べて表示します2:チップがクリックされたときA:それがされたことを示すために境界線で強調表示します選択されたB:テキストフィールド/おそらく非表示フィールドの値を適切な色の名前に変更します(したがって、画像にインディゴ、ソラリアなどのフラグを付け、それに応じて更新する必要があります)
Stackoverflowでこの投稿を見つけましたが、機能させることができませんでした:jQuery image picker
そして、これが上記のリンクに基づく私の現在のコードです
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
$('div#image_container img').click(function(){
// set the img-source as value of image_from_list
$('input#image_from_list').val( $(this).attr("src") );
});
</script>
</head>
<body>
<div id="image_container">
<img src="images/vermillion.jpg" />
<img src="images/riverway.jpg" />
<img src="images/solaria.jpg" />
</div>
<form action="" method="get">
<input id="image_from_list" name="image_from_list" type="text" value="" />
</form>
</body>
</html>
どんな助けでも大歓迎です!!!!
さて、私は実際に問題を修正することになりました、そしてこれが私が使用したコードです
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div id="image_container">
<img src="images/vermillion.jpg" col="red" border="0" />
<img src="images/riverway.jpg" col="blue" border="0" />
<img src="images/solaria.jpg" col="yellow" border="0" />
</div>
<form action="" method="get">
<input id="image_from_list" name="image_from_list" type="text" value="" />
</form>
<script>
$("div#image_container img").click(function () {
$("div#image_container img").attr("border","0");
$(this).attr("border","4");
$("input#image_from_list").val($(this).attr("col"));
});
</script>
</body>
</html>