1.

Solve : Passing Variable value from js to php variable., : hel!!!?

Answer»
  Good day,,
    Im using the jquery modal form.,. I have a problem with this JavaScript and php HOPE someone help me..Im trying to PASS a variable from javascript to PHP, I tried a lot but it did'nt work.,.
Here's my sample code:

    $("#dialog").dialog({
               bgiframe: true,
               autoOpen: false,
               height: 300,
               modal: true,   
               buttons: {
                  'Add New Partner': function() {
                     var bValid = true;
                     allFields.removeClass('ui-state-error');
      
                     bValid = bValid && checkLength(cat,"CATEGORY",1,4);
                     bValid = bValid && checkLength(code,"Partner Code",1,5);
                     bValid = bValid && checkLength(desc,"Description",5,20);
      
                     bValid = bValid && checkRegexp(code,/^([0-9a-zA-Z])+$/,"Product Code only allow : a-z 0-9 ");            
                     bValid = bValid && checkRegexp(desc,/^([0-9a-zA-Z])+$/,"Description field only allow : a-z 0-9");
                     
               if (bValid) {
                                      // Here's the main problem                                                        
                                // insert the value from cat.val(), code.val() and desc.val() into the database table

                      $(this).dialog('close');
                  }
               },
            Cancel: function() {
                  $(this).dialog('close');
                  }
            },
               close: function() {
                  allFields.val('').removeClass('ui-state-error');
               }            
            });
            

    You'll need to send your javascript variables to another PHP page I guess - probably by means of an AJAX query.  I'm not entirely clear of what you're trying to do though, and what's the workflow on this page.I already figure it out,., since im using codeigniter., and redirect to the main page..
I just pass the variable through the url., Quote from: r3ynz_t4nz on June 17, 2009, 02:04:13 AM
I just pass the variable through the url.,

That seems like the logical way to do it. Just put your JavaScript inside PHP and then SET a PHP variable inside the JS.It's tidier to pass the variable via a POST call though - especially if you are passing lots of variables. Quote
Just put your JavaScript inside PHP and then set a PHP variable inside the JS.
can you site an example please..


Discussion

No Comment Found