Reputation: 3920
Am new to JQuery. I want to pass the selected radio button values on button click and show that selected radio button values in textboxes and comboboxes.
I dont know how it can be done.
My current code as follows.displayjobs()
displays the table with values in page load.
function displayjobs() {
$('#jobsTable').empty();
$("#jobsTable").append("<tr><th>Id</th><th>Operating System</th><th>Browser</th><th>version</th><th>testscript</th><th>server</th></tr>");
$.ajax({
type: 'GET',
url: "/getJobs",
dataType: "json",
success: function (jobs) {
alert(jobs);
if (jobs.length == 0) {
alert("There are no scheduled Jobs");
$("#jobsTable").hide();
} else {
//jobs.forEach(function(job) {
$.each(jobs, function (key, value) {
alert(value.server);
var tabString = '<tr><td>' + value.jobid + '</td><td>' + value.os + '</td><td>' + value.browser + '</td><td>' + value.version + '</td><td>' + value.script + '</td><td>' + value.server + '</td><td>' + '<input type="radio" name="joblist" id= ' + value.jobid + 'value=' + value.jobid + '/> </td></tr>';
$("#jobsTable").append(tabString);
});
}
}
});
}
In button onClick showdata()i have to show the selected radio button values to text boxes and comboboxex
<h3>List Jobs</h3>
<div>
<h1 style="padding: 10px;">Jobs In Database</h1>
<div id="jobTable" style="padding-left: 50px;">
<div style="padding: 5px; padding-left: 0px;">
<table id="jobsTable" border="1">
</table>
<input type="button" id="show" value="showrecord" onclick="showdata();"/>
</div>
</div>
<br/>
</div>
<div id="manage">
<div>
<label>Operating Systems</label>
<select id="OS" onchange="browserlist();">
<option value="win7 32">Windows 7 - 32 </option>
<option value="win7 64">Windows 7 - 64 </option>
<option value="Vista 32">Windows Vista - 32</option>
<option value="Vista 64">Windows Vista - 64</option>
<option value="Win8 X64">Windows 8 - X64</option>
</select>
</div>
<div>
<label>Browsers</label>
<select id="browsers" onchange="browserDet();">
<option value=""></option>
</select>
</div>
<div>
<label>Versions</label>
<select id="version">
</select>
</div>
<div>
<label>Test Scripts</label>
<select id="testscriptlist">
<option value=""></option>
<option value=""></option>
</select>
</div>
<div>
<label>Server:</label>
<input type="text" id="server" value="" />
</div>
<br/>
</div>
Upvotes: 0
Views: 1690
Reputation:
function showdata(){
var $tr=$('input:radio:checked').parent().parent(); //will give you the tr
var jobid= $tr.find("td:eq(0)").html(); //first td text
var os= $tr.find("td:eq(1)").html(); //second td text....
.....
var server=$tr.find("td:eq(5)").html();
$("#OS").append("<option value='"+os+"' selected>"+os+"</option>"); //to add an option to select
$("#server").val(server); //to add value to text box
}
Upvotes: 1