How to get value or radio input into a hidden field when opened in thickbox?

Hi,

I am using thickbox to open up a page which has few radio buttons, upon selecting a radio button the value should go into the hidden field (on the page from which thickbox was opened) and thickbox should close

OR

The page is opened in thickbox and I have several a href links upon clicking a link a value is filled into the hidden field (on the page from which thickbox was opened) and thickbox should close.

How do I achieve that ?

Thanks.

Hi,

Its weird that I did’nt get any response on sitepoint, but I am posting my solution:

<html>
<head>
<title>Tets</title>

<link rel="stylesheet" href="cb/colorbox.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="cb/jquery.colorbox-min.js"></script>

<script>
	$(document).ready(function(){
		//Examples of how to assign the Colorbox event to elements
		$(".ajax").colorbox({ width:"75%", height:"75%"});
	});
</script>


</head>

<body>

<form id="frmAddEvnt">
<a class="ajax" href="preview.html">View</a>
<input type="text" id="banner" name="banner" />
</form>

</body>
</html>

preview.html file which opens in thickbox/colorbox

<html>
<head>
<title>Tets</title>

<script>
function putinfield(val) {
	document.getElementById("banner").value = val;
	 $.colorbox.close();
}
</script>

</head>

<body>

<a onclick="putinfield('1');"><img src="1.jpg"></a>
<a onclick="putinfield('2');"><img src="2.jpg"></a>
<a onclick="putinfield('3');"><img src="3.jpg"></a>
<a onclick="putinfield('4');"><img src="4.jpg"></a>

</body>
</html>

Hope this helps.

Thanks.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.