php - Jquery tabify with form (Multiple Instances problem ?) -
i'm using jquery tabify 4 tabs , each content same form calling via ajax.(assume form.php) 1st tab works fine form. 2nd,3rd , 4th tab failed input type="text" value
tabify field (4 tabs here make short code long):
$(document).ready(function () { $('#general_information_tab').tabify(); }); function recp(refer,id,plan){ if(plan == 0) { $('.stgcontent').load('stage/stage_procedure1.php?plan_id=' + id + '&t_referid=' + refer ); }else{ $('.stgcontent').load('stage/new_taskstg.php?plan_id=' + id + '&t_id=' + refer); } <div id="general_tab_content"> <ul id="general_information_tab" class="general_information_tab"> <li class="active"><a href="#one" onclick="recp('1','<?php echo $plan_id; ?>','0')" >immediate response steps</a></li> <div id="one" class="content_gi"> <div class="stg1"> <a href="#" onclick="recp('1','<?php echo $plan_id; ?>','1')" class="stg1"><img src="images/task/add.ico" height="10px" width="10px" /> add task</a> <div class="stgcontent"> <script type="text/javascript"> recp('1','<?php echo $plan_id; ?>','0'); </script> </div> </div> </div>
in new_taskstg.php
$(function(){ $(".newtasksubmitbtn").click(function(){ var t_content = $(".task_name").val(); var t_referid = $(".refer").val(); var save_plan = $(".plan").val(); var v_id = $(".vendor").val(); var datastring='t_content=' + t_content + '&t_referid=' + t_referid + '&save_plan=' + save_plan + '&v_id=' + v_id; alert(t_content + t_referid + save_plan + v_id); if(t_content=='' || t_referid=='' || save_plan=='' || v_id=='') { //error message $(".fail").show(); $(".success").hide(); } else { $.ajax({ type: "post", url: "stage/insert.php", data: datastring, success: function(data){ //success message $(".success").show(); $(".fail").hide(); } }); } return false; }); });
form field code:
<input type="text" name="task_name" class="form_input task_name" />
test did :
as above var t_content = $(".task_name").val(); , prompt alert(t_content); shows on 1st tab able capture while 2nd 3rd , 4th tab failed...
was suspecting multiple instances problem...
problem solved. mian point avoid multiple instances since tabify couldn't differentiate tab form , takes 4 tabs together. solve case use unique id in 4 forms.
Comments
Post a Comment