I am calling a javascript function from within my razor code..but the jquery code within my javascript function doesnot get executed..
what is the correct way of doing it.
function getPosition(id) { var c = '#' + id; return $c.index(); }
My HTML Table
<tbody>
<tr>
<td>
@foreach(Result geResults in Model.results)
{
@:
<script>
{
getPosition(@geResult.assessmentId);
}
</script>
}
</td>
</tr>
<\tbody>
UPDATE
As everybody is getting confused i am posting more detail
<table>
<thead>
<tr>
@foreach (Assessment geAssessment in Model.assessments)
{
<th [email protected]>@geAssessment.Name</th>
}
</thead>
<tbody>
<tr>
@{
// add a td for each assessment in body
foreach(Assessment geAssessment in Model.assessments)
{
<td>
@foreach (ShortResult geResult in Model.results)
{
@:
<script>
{ getPosition(@geResult.assessmentId);
}
</script>
}
</td>
}
}
</tr>
</tbody>
i want to return the column index in getPosition function and then print it in the td..hope this clears out any confusions
currently it says getPosition is out of context whereas intellisense shows me getPosition when i code
$cis not defined. You mean$(c).return $('#' + id).index();. also u need to visit this api.jquery.com/index@geResult.assessmentIdand do you have any element with id of @geResult.assessmentId's value?