Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
156
rated 0 times [  159] [ 3]  / answers: 1 / hits: 40033  / 11 Years ago, wed, november 27, 2013, 12:00:00

I'am a newbie here trying to set a value of a hidden field on button click fetching value from a radio button. For some reason I'am able to alert the value but while assigning, it always gives me null.



Please help.



Thanks in advance.



<script type=text/javascript>
function deleteCheck(){
var values = document.getElementById(deleteVisitID).checked;

if (values) {
var hiddenInput = document.getElementById('deleteIDValue');
*hiddenInput.value=document.getElementById(deleteVisitID).value;* <---- throws error

window.open(DeleteAppointmentSelected.jsp,'_self',false);
}else{
alert('Please Enter a ID before submitting');
}
}

</script>





on the form



<table border=1>
<tr><th>visit_id</th><th>visit_date</th><th>visit_time</th><th>physician_id</th><th>Delete Visit</th></tr>
<%
while(visitsForPatient.next()){
%><tr>
<td>
<% visit_id=visitsForPatient.getString(1);%>
<%=visit_id %>
</td>
<td>
<%visit_date=visitsForPatient.getString(2);%>
<%=visit_date %>
</td>
<td>
<%visit_time=visitsForPatient.getString(3);%>
<%=visit_time %>
</td>
<td>
<%physician_id=visitsForPatient.getString(4);%>
<%=physician_id %>
</td>
<td>
<input type=radio name=deleteVisitID id=deleteVisitID value=<%=visit_id %>/>
</td>


</tr>

<%

}
%></table><input type=hidden name=deleteIDValue/>

More From » html

 Answers
9
<input type=hidden name=deleteIDValue/>


Needs to have an ID attribute:



<input type=hidden name=deleteIDValue id=deleteIDValue/>


For this line in your script to work:



document.getElementById('deleteIDValue')


At the moment, you are trying to find an element with ID deleteIDValue which does not exist on the page. Therefore, you cannot call .checked or .value on a non-existent object, which is where you are getting the error.


[#74039] Monday, November 25, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marques

Total Points: 366
Total Questions: 108
Total Answers: 111

Location: Burundi
Member since Wed, Nov 25, 2020
4 Years ago
;