Wednesday, December 31, 2014

accessing input tag values(which are created dynamically) from html in backend(python) using post method

Hi guys i am new to html and javascript. my application is to create a table from a list of list went from backend, after creating them dynamically(as length of the list is not known) i need to access some particular values of the table in python backend, when i tried to do this i am able to fetch the value in backend, but the value is not the desired value. The value which it returns is the last element of that table.

given below is my code

 {% for result in list1 %}
 <tr id="tr_id">
    <!-- <form id="listOfSearch{{result.0}}" name="listOfSearch" method="post" action="/fetch_candid/"> -->
    <form id="listOfSearch{{result.0}}" name="listOfSearch" method="post" action = "/fetch_candid/">
   
     <td>
    <a href="#" onclick="document.forms['listOfSearch{{result.0}}'].submit();">{{result.0}}
    <input name="uniqID" value="{{result.0}}" id="IdField" type="hidden" >
    </a></td>

    <input  name="save" value="0" type="hidden">
   
    <input  name="listresult" value="{{list1}}" type="hidden">
     <input type="hidden" id="statusofresume123" name="statusofresume123" value="{{sres}}">
      <input type="hidden" id="Client1" name="Client1" value="{{client}}">
      <input type="hidden" id="ReqId1" name="ReqId1" value="{{reqid}}">
      <input type="hidden" id="only_skills" name="only_skills" value="{{only_skills}}">
      <input type="hidden" id="mbno" name="mbno" value="{{mbno}}">
     <input type="hidden" id="ReqId" name="ReqId" value="{{reqid4}}">
      <input type="hidden" id="Client" name="Client" value="{{client2}}">
       <input type="hidden" id="Name" name="Name" value="{{Name}}">
       <input type="hidden" id="datepicker" name="datepicker" value="{{Date1}}">
       <input type="hidden" id="datepicker1" name="datepicker1" value="{{Date2}}">
       <!-- <form id="listOfSearch{{result.0}}" name="listOfSearch" method="post" action="/fetch_candid/"> -->
    <td style="padding:5px; width:50px;">
   
   
    <select style="padding:5px; width:102%;"  onchange="savestate({{result.0}});" class="select11" id="status8" name="status8" title="Choose Status">
     <option id="status8"  name="status8" >{{result.1}}</option>
     
     
     {% if result.1 == "HR_Interview" %}
     
      <option id="status8"  name="status8">COL</option>
     
     
      {% elif result.1 == "Internal_Interview" %}
     
      <option id="status8"  name="status8">HR_Interview</option>
      <option id="status8"  name="status8">COL</option>
     
     
      {% elif result.1 == "COL" %}
     
      <option id="status8"  name="status8">CS</option>
     
     
      {% elif result.1 == "CI" %}
     
      <option id="status8"  name="status8">CIS</option>
     
     
      {% elif result.1 == "CIS" %}
     
      <option id="status8"  name="status8">Joining</option>
     
     
     
     {% elif result.1 == "CS" %}
     
      <option id="status8"  name="status8">CI</option>
     
     
      {% elif result.1 == "Line_up" %}
     
      <option id="status8"  name="status8">Internal_Interview</option>
       <option id="status8"  name="status8">HR_Interview</option>
       <option id="status8"  name="status8">COL</option>
     
     {% endif %}
     
      </select>
       <input class="css_save1" type="submit" name="save" value="Save" onclick = "function9(this);">
       <input type="hidden" id="name" name="name" value={{name}}>

<input name="uniqID1" value="{{result.0}}" id="IdField" type="hidden" >
<input type="hidden" id="name" name="name" value={{name}}>
</td>

 <!-- </form>  -->
 

    <td class="reqid1">{{result.2}}</td>
    <td>
    {{result.3}}
    <input name="Client18" id="Client18" type="hidden" value="{{result.3}}">
    </td>
    <td>
    {{result.4}}
    <input name="name18" id="name18" type="hidden" value="{{result.4}}">
    </td>
    <td>{{result.5}}</td>
    <td>{{result.6}}</td>
    <td>{{result.7}}</td>
    <td>{{result.8}}</td>
    <td>{{result.9}}</td>
    <td>{{result.10}}</td>
    <td>{{result.11}}</td>
    <td>{{result.12}}</td>
    <td>{{result.13}}</td>
    <td>{{result.14}}</td>
    <td>{{result.15}}</td>
    <td>{{result.16}}</td>
    <td>{{result.17}}</td>
   
<input type="hidden" id="name" name="name" value={{name}}>
      </form>
       
<script>
    function function9(x)
    {
    var id = $(x).closest("tr").find('td:eq(1)').find("#status8 option:selected").text();
    var Client18 = $(x).closest("tr").find('td:eq(3)').text();
    var name18 = $(x).closest("tr").find('td:eq(4)').text();
    console.log("fetched value>>>",id,Client18,name18);         
         if (id == "COL")        
                {
                var r=confirm("Do you want to generate COL NOW ?");
                    if (r == true)
                    {
                    alert("before");
                    document.getElementById("listOfSearch{{result.0}}").action ="/hrpage/";
                    document.getElementById("listOfSearch{{result.0}}").method = 'POST';
                    document.getElementById("listOfSearch{{result.0}}").submit();
                    alert("after");
                    }
                    else
                    {
                    document.getElementById("listOfSearch{{result.0}}").submit();
                    }
                }
        else
                {
                document.getElementById("listOfSearch{{result.0}}").submit();
                }
        <!-- return response; -->
    }
</script> 
 my application is when i press on the save button i need to get that particular row's client name and candidate name
kindly help me with this

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9a653b59-bb32-43a7-8095-edfe5308ba45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment