Sending particular input value among input array into javascript
<p>i have a question, i am using a query to populate a list of messages by using a loop..here's my code</p>

<pre><code>&lt;?php
$sql_i_msg_sent_waiting="SELECT t1.i_message_id,t2.username,t2.name,t2.propic,t2.age,t2.dob,t3.religion,t3.caste 
FROM candidate_i_message as t1, candidate_register_table as t2, candidate_social_table as t3 WHERE t1.from_username='$_SESSION[logged_user]' AND t1.to_username=t2.username AND t2.username=t3.username AND t1.status='0'";
$result_i_msg_sent_waiting=mysql_query($sql_i_msg_sent_waiting,$con);
$count=mysql_num_rows($result_i_msg_sent_waiting);
echo $count;

?&gt;



&lt;div id="section_i_message_sent_waiting" style="width:650px; overflow:auto;"&gt;
         &lt;h2&gt;Awaiting Sent Request&lt;/h2&gt; 
          &lt;?php
          if(mysql_num_rows($result_i_msg_sent_waiting)==0)
           {
            ?&gt;
            &lt;div style="width:650px; border-bottom:1px solid #CCCCCC" align="center"&gt;
            &lt;table border='0' cellspacing='0' cellpadding='0' width='550px' align='center'&gt;
            &lt;tr style='padding-botton:5px; border-bottom:1px solid #CCCCCC'&gt;
            &lt;td width='50px'/&gt;
            &lt;td&gt;&lt;FONT COLOR=red FACE='Geneva, Arial' SIZE=2&gt;
                       No Messages Found.&lt;/FONT&gt;&lt;/td&gt;
                    &lt;td width='50px'/&gt;&lt;/tr&gt;&lt;/table&gt;
            &lt;/div&gt;      

         &lt;?php
         }
         else
         {
         while($row_i_msg_sent_waiting=mysql_fetch_array($result_i_msg_sent_waiting))
         {
         ?&gt;
         &lt;div style="width:650px; border-bottom:1px solid #CCCCCC" align="center"&gt;
           &lt;table width="550px" cellpadding="0" cellspacing="0" border="2" align="center" style="vertical-align:middle"&gt;
           &lt;tr style='vertical-align:middle'&gt;
           &lt;td style='vertical-align:middle' width="100px"&gt;
           &lt;form method='post' action='id.php' name='showid' id='showid'&gt;
           &lt;input type='hidden' name='pro_username' id='pro_username' 
             value="&lt;?php echo $row_i_msg_sent_waiting['username'];?&gt;"/&gt;
                     &lt;input type='image' src='&lt;?php echo $row_i_msg_sent_waiting['propic'];?&gt; ' style="width:100px; vertical-align:middle"/&gt;
         &lt;/form&gt;
           &lt;/td&gt;
           &lt;td style='vertical-align:middle;border-right:1px solid #CCCCCC;border-top:1px solid #CCCCCC' width="450px" &gt;
               &lt;table width="450px" cellpadding="0" cellspacing="0" border="0"&gt;
                 &lt;tr&gt;
                 &lt;td width="10px"/&gt;
                 &lt;td width="100px" align="left"&gt;Name&lt;/td&gt;
                 &lt;td width="10px"&gt;:&lt;/td&gt;
                 &lt;td width="100px" align="left"&gt;&lt;?php echo $row_i_msg_sent_waiting['name'];?&gt;
                 &lt;/td&gt;
                 &lt;td width="10px"&gt;
                 &lt;td width="100px" align="left"&gt;Age&lt;/td&gt;
                 &lt;td width="10px"&gt;:&lt;/td&gt;
                 &lt;td width="100px" align="left"&gt;&lt;?php echo $row_i_msg_sent_waiting['age'];?&gt;
                 &lt;/td&gt;
                 &lt;td width="10px"/&gt;
                 &lt;/tr&gt;
                  &lt;tr&gt;
                 &lt;td width="10px"/&gt;
                 &lt;td width="100px" align="left"&gt;Date Of Birth&lt;/td&gt;
                 &lt;td width="10px"&gt;:&lt;/td&gt;
                 &lt;td width="100px" align="left"&gt;&lt;?php echo $row_i_msg_sent_waiting['dob'];?&gt;
                 &lt;/td&gt;
                 &lt;td width="10px"&gt;
                 &lt;td width="100px" align="left"&gt;Religion&lt;/td&gt;
                 &lt;td width="10px"&gt;:&lt;/td&gt;
                 &lt;td width="100px" align="left"&gt;&lt;?php echo $row_i_msg_sent_waiting['religion'];?&gt;
                 &lt;/td&gt;
                 &lt;td width="10px"/&gt;
                 &lt;/tr&gt;
                 &lt;tr&gt;
                 &lt;td width="10px"/&gt;
                 &lt;td width="100px" align="left"&gt;Caste&lt;/td&gt;
                 &lt;td width="10px"&gt;:&lt;/td&gt;
                 &lt;td width="100px" align="left"&gt;&lt;?php echo $row_i_msg_sent_waiting['caste'];?&gt;
                 &lt;/td&gt;
                 &lt;td width="10px"&gt;
                 &lt;td width="100px" align="left"&gt;Religion&lt;/td&gt;
                 &lt;td width="10px"&gt;:&lt;/td&gt;
                 &lt;td width="100px" align="left"&gt;&lt;?php echo $row_i_msg_sent_waiting['religion'];?&gt;
                 &lt;/td&gt;
                 &lt;td width="10px"/&gt;
                 &lt;/tr&gt;
                 &lt;tr&gt;
                 &lt;td width="10px"/&gt;
                 &lt;td width="100px" align="left"&gt;Action&lt;/td&gt;
                 &lt;td width="10px"&gt;:&lt;/td&gt;
                 &lt;td width="100px" align="left"&gt;
                 &lt;form method="post" name="cancel_request_form"  id="cancel_request_form"
                 action="javascript:cancel_request(document.getElementById('cancel_request_form'));"&gt;
                 &lt;input type="text" name="no_of_msg" id="no_of_msg" value="&lt;?php echo $count;?&gt;"/&gt;
                    &lt;input type="text" name="cancel_request[]" id="cancel_request[]" 
                    value="&lt;?php echo $row_i_msg_sent_waiting['i_message_id'];?&gt;"/&gt;
                    &lt;input type="submit" name="cancel" id="cancel" class="button" style="width: 100px" value="Cancel Request"/&gt;
                    &lt;/form&gt;
                 &lt;/td&gt;
                 &lt;td width="10px"&gt;
                 &lt;td width="100px" align="left"&gt;&lt;/td&gt;
                 &lt;td width="10px"&gt;:&lt;/td&gt;
                 &lt;td width="100px" align="left"&gt;
                 &lt;/td&gt;
                 &lt;td width="10px"/&gt;
                 &lt;/tr&gt;
                             &lt;/table&gt;
           &lt;/td&gt;
           &lt;/tr&gt;

           &lt;/table&gt;
         &lt;/div&gt;
         &lt;?php 
         } 
         }?&gt;

&lt;/div&gt;
</code></pre>

<p>the line </p>

<pre><code>&lt;input type="text" name="cancel_request[]" id="cancel_request[]" 
                    value="&lt;?php echo $row_i_msg_sent_waiting['i_message_id'];?&gt;"/&gt;

                creates a array of input type text, and each input text contains corressponding message_id...since each input text is contained within a form, and since the form is within a loop, the form is also repeatative..when the submit button will be clicked corressponding to a particular form, the input type text[] within that form will fire the value to get accepted in the javascript i give below...

&lt;script&gt;
function cancel_request(obj) {

alert(document.getElementByName('cancel_request[]').value);
}
&lt;/script&gt;
</code></pre>

<p>but the script is showing problem, its not working at all...i dnt know whats wrong..its not displaying anything..i want say there is message_id 1 and 2..one text type input[] contains value 1, another value 2..when i click the submit button corresponding to value 1, the value of that text type input will be send to javascript and displayed...whats prob with my script?? please help me</p>

<p><strong>Special Request</strong></p>

<p>please read with patience and understand, without understanding dnt degrade my point reputation...some people do such things</p>
