views:

39

answers:

2

hi all..i'm using jquery tabs.. i'm use tabs-1 as input form and tabs-2 as show input data... i want after submit..all value inside textfield which have been type at tabs-1 can copy into textfield at tabs-2...

where part that i must modify?at form or at process page?what's code that can make it works?

 <script type="text/javascript">
        $(document).ready(function() {

         $("#input").click(function() {
        if($("#submit").valid()) {
                var params=$("#submit").serialize();
                $.ajax({
                        type:"post",
                        url:"process1.php",
                        data:params,
                        cache :false, 
                        async :false,
                        success : function() {  

that is for submitting form inside tabs-1...at tabs-2:

<tr>
    <td width="100"><input type="text" id="showline" name="showline"<? echo "$_postVar('line')" ?>/></td>
    <td width="100"><input type="text" id="showmodel" name="showmodel"<? echo "$_postVar('model')" ?>/></td>
    <td width="100"><input type="text" id="showNIK" name="showNIK"<? echo "$_postVar('id')" ?>/></td>
</tr>
A: 

Well, if I understand this correctly, you can use the callback on the AJAX function to do that (so that the submitted info is only displayed if the request was successful):

[...]
success : function() {
    $('#showline').val($('#faline').val());
    $('#showmodel').val($('#modelnm').val());
    $('#showNIK').val($('#NIK').val());
};
[...]

assuming that #faline, #modelnm and #NIK are the IDs of the input fields in the form from which the data is being submitted.

Also, in the HTML you don't need to echo anything anymore (which has incorrect syntax - it would be value="<? echo ... ?>" anyways) since the values will be added by jQuery.

Hope this helps !

FreekOne
@freekOne:for #showline it works..but for #showmodel and #showNIK it doesn't work...why?
klox
If the data is properly submitted (and I suppose it is since it passes validation, ASSUMING the validation itself works properly), the culprits are most likely the IDs. Could you please update your answer to include the code for the form from which the data is being submitted ? It's hard to tell only from the snippets that you've posted.
FreekOne
@freekOne:u can look at my answer..
klox
I meant the form, not the jQuery script because I wanted to see the IDs that you are using on the form from which the data is being submitted. Do I take it you managed to get it working after changing the IDs ?
FreekOne
A: 
 $("#model").change(function() {
                                 var barcode;   
                                 barCode=$("#model").val();
                                 var data=barCode.split(" ");
                                 $("#model").val(data[0]);
                                 $("#serial").val(data[1]);
                                 var str=data[0];
                                 var matches=str.match(/[T|EE|EJU].*D/i);


  $("#input").click(function() {
        if($("#submit").valid()) {
                var params=$("#submit").serialize();
                $.ajax({
                        type:"post",
                        url:"process1.php",
                        data:params,
                        cache :false, 
                        async :false,
                        success : function() {  
                                                $('#showline').val($('#line').val());
                                                $('#showmodel').val($('#model').val());
                                                $('#showNIK').val($('#id').val());
                                                $("#model").val("");
                                                $("#serial").val("");
                                                $("#line").val("");

i put freekOne code before set .val("");

klox