Привет, у меня есть таблица в одном td, у меня есть текст, а в другом td у меня есть кнопка выбора
нажав кнопку выбора, мне нужно выбрать текст немедленного предыдущего текста td.
Я знаю, что могу сделать это с помощью.prev(), но я не знаком с этим методом, и кто-нибудь может мне помочь.
мой скрипт
function ReLoadMedications(mid) {
var ProductName = "This shouled get the value of prev td text";
var dea = $("input[type='button'][mid='"+mid+"']").attr('id');
var mid = $("input[type='button'][mid='" + mid + "']").attr('mid');
var form = $("input[type='button'][mid='" + mid + "']").attr('form');
var href = $("input[type='button'][mid='" + mid + "']").attr('href');
var con = false;
var fax = false;
alert(ProductName + "\n" + dea + "\n" + mid + "\n" + form + "\n" + href + "\n" + con + "\n" + fax);
}
У меня есть код здесь, в JS Fiddle, а также ниже:
<div class="t-widget t-grid" id="TherapeuticAltGrid">
<table cellspacing="0">
<colgroup><col style="width:200px"><col></colgroup>
<thead class="t-grid-header">
<tr>
<th class="t-header" scope="col" style="display:none">
<a class="t-link" href="/BenefitsFormulary/HealthPlanInformation?PatientID=17&MedicationID=6235&MedicationName=LIPITOR%20EQ%2010MG%20BASE%20TABLET&isFax=false&form=TABLET&TherapeuticAltGrid-orderBy=MedicationID-asc">Medication ID</a>
</th>
<th class="t-header" scope="col">
<a class="t-link" href="/BenefitsFormulary/HealthPlanInformation?PatientID=17&MedicationID=6235&MedicationName=LIPITOR%20EQ%2010MG%20BASE%20TABLET&isFax=false&form=TABLET&TherapeuticAltGrid-orderBy=Medication-asc">Medication</a>
</th>
<th class="t-header" scope="col">
<span class="t-link"> </span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="display:none;">
1147
</td>
<td>
DACTINOMYCIN INJECTABLE 0.5MG/VIAL
</td>
<td class="t-last">
<input type="button" value="Select" class="MedicationClicked button" mid="1147" id="0" form="INJECTABLE" onclick="ReLoadMedications(1147)">
</td>
</tr>
<tr class="t-alt">
<td style="display:none;">
1439
</td>
<td>
PROVENTIL SOLUTION EQ 0.5% BASE
</td>
<td class="t-last">
<input type="button" value="Select" class="MedicationClicked button" mid="1439" id="0" form="SOLUTION" onclick="ReLoadMedications(1439)">
</td>
</tr>
<tr>
<td style="display:none;">
1605
</td>
<td>
EMETE-CON INJECTABLE EQ 50MG BASE/VIAL
</td>
<td class="t-last">
<input type="button" value="Select" class="MedicationClicked button" mid="1605" id="0" form="INJECTABLE" onclick="ReLoadMedications(1605)">
</td>
</tr>
</tbody>
</table>
<div class="t-grid-pager t-grid-bottom">
<div class="t-status">
<a class="t-icon t-refresh" href="/BenefitsFormulary/HealthPlanInformation?PatientID=17&MedicationID=6235&MedicationName=LIPITOR%20EQ%2010MG%20BASE%20TABLET&isFax=false&form=TABLET">Refresh</a>
</div>
<div class="t-pager t-reset">
<a class="t-link t-state-disabled" href="#"><span class="t-icon t-arrow-first">first</span></a><a class="t-link t-state-disabled" href="#"><span class="t-icon t-arrow-prev">prev</span></a>
<div class="t-numeric">
<span class="t-state-active">1</span><a class="t-link">2</a><a class="t-link">3</a><a class="t-link">4</a><a class="t-link">5</a><a class="t-link">6</a><a class="t-link">7</a><a class="t-link">8</a><a class="t-link">9</a><a class="t-link">10</a><a class="t-link">...</a>
</div>
<a class="t-link" href="#"><span class="t-icon t-arrow-next">next</span></a><a class="t-link" href="#"><span class="t-icon t-arrow-last">last</span></a>
</div>
<div class="t-status-text">
Displaying items 1 - 3 of 41
</div>
</div>
</div>