Jump to content

giba

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Contact Methods

  • MSN
    gilberto_albino@hotmail.com

Profile Information

  • Gender
    Male
  • Location
    Brazil

giba's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi there, everybody. I am with a situation here. I must export some datas to a specific program written in Java and this program needs to import the datas counting the characters for with field, this way, I need to insert white spaces fo fullfill a count of characters. See the example below for a student: ID = 6 chars NAME = 30 chars AGE = 2 chars FATHERNAME = 30 chars MOTHERNAME = 30 chars In this case, if I have to export JOHN WHITE, ID 123456, 10 YEARS OLD, son of GILBERT WHITE and JANET WHITE: I must have: 6 chars 30 2 30 30 ______________________________________________________________________________ | | | | |<-ends here 123456JOHN WHITE 10GILBERT WHITE JANETE WHITE Is there a function for solving this, or some logic way to get it? Thanks in advance!
  2. I think I din't make it very clear. What I wanted was to serialize the values of checkboxes after clicking somewhere else in the page to send it to ajax GET request. After some logics I got it, but I would like to know if there is a better approach now: <html> <head> <title>Serializing Checkbox</title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready( function() { $("#test").click( function() { serializeCheckbox(); } ); } ); function serializeCheckbox() { var string = '&string='; var inputs = document.getElementsByTagName('input'); for( var x = 0; x < inputs.length; x++ ) { if(inputs[x].type == "checkbox" && inputs[x].name == 'field') { if(inputs[x].checked == true) { string += inputs[x].value + ','; } } } if (/,$/.test(string)) { string=string.replace(/,$/,"") } alert(string); } </script> </head> <body> <form> <input type="button" id="test" value="Click me" /> <br /> <input name="field" type="checkbox" value="blue" />Blue<br /> <input name="field" type="checkbox" value="red" />Red<br /> <input name="field" type="checkbox" value="green" />Green<br /> </form> </body> </html>
  3. Hi there! I need to get the values from multiple checkboxes and turn it into a string for sending it to an Ajax Get Request when checking the boxes, not when sending it to the server throw submit button. Because, I need to make the values of form fields available again after leaving the page without submiting the form, and coming back to that: <input name"field[]" value="blue" /> <input name"field[]" value="red" /> <input name"field[]" value="green" /> Should be stored in a PHP Session like this "blue,red,green", for when sending to Ajax it should be stored by PHP like. S_SESSION['field[]'] = "blue,red,green"; To have it loaded when the page is refreshed and exploded through PHP to select each box accordingly. I've also tried to concatenate the values throw a loop, but no sucess. I am using jQuery and have no ideia of how to accomplishing this task in Javascript with jQuery, I am not a newby in Javascript nor jQuery, but I don't know how to do such task. Hope someone could help me! Thanks in Advance!
  4. After dealing a lot with GET requests I found that IE limits the value of 500 charactes per value of a parameter in the Query String, so I dealt with this fragmenting my code in more peaces. Not the best choise, but works!!!!
  5. Hi there! I am issuing a problem with IE that I can't solve it, because in all other browsers it work perfectly. I did a simple script that gets the HTML from an element by its class name, send it via ajax and gets the result from a .php file which contains a Google script for translation, the problem however is that only Internet explorer returns nothing. The question is: How can I send the HTML of an element and get it back on IE based on a loop that cicles AJAX requests? Follows de script I used: The code for getting the element by its class name: document.getElementsByClassName = function(class_name) { var docList = this.all || this.getElementsByTagName('*'); var matchArray = new Array(); var re = new RegExp("(?:^|\\s)"+class_name+"(?:\\s|$)"); for (var i = 0; i < docList.length; i++) { if (re.test(docList[i].className) ) { matchArray[matchArray.length] = docList[i]; } } return matchArray; } The code for looping through the elements with the class "translate": var trans = document.getElementsByClassName('translate'); for ( var i = 0; i < trans.length; i++) { t = trans[i]; translate(t,'translate.php?string='+escape(t.innerHTML.replace(/[\r\n]+/g, ""))+'&l=<?=$_GET['l'];?>&c='+Math.random()) } And the code for AJAX: function translate(target, url) { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support XMLHTTP!"); } xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4) { target.innerHTML = xmlhttp.responseText; //alert(xmlhttp.responseText); } } xmlhttp.open("GET", url, true); xmlhttp.send(null); }
  6. Hey, I tested your script and put the CSS together. In fact, the only wrong thing is to compare '0' to an integer, but taking the quotes and passing it as zero, I couldn't see any error. NOTE: What browser are you using? 'Coz once a time when coding a site there was a time when the browser wasn't receiving the refresh from the server. So I cleaned my temporary files and restarted the browser and everything went right again...
  7. Well, I've found that the line: ( $i % 7 ) does the trick for Sundays. So now, I can style the Sunday based on this operation.
  8. Well thorpe, I am also inclined to believe that it is discontinued... And, yes, corbin... you can run java inside PHP, however only on PHP 4.
  9. Hum, I have already read the manual. It doesn't teaches you how to install. it says to go to pecl site, however there isn't any library called java nor how to install it. And any information on the php site is for php 4 on windows.
  10. Hi there, does some good guy here know how to integrate PHP and Java on LInux with php 5? I am hardly trying to search such information on search engines but it seems to be a top secret answer. Cant't find out even which library to install on I am running PHP 5.2.6 on Linux Ubuntu and Apache 2.2.8. Hope someone could help me.
  11. Yes, I know it, but I would like to know how to make the calendar do some action if the day is a Sunday, like to make it in bold. How do I implement it, because I have a number for the days and what is exactly the relation between the days and the date('l',$timestamp). What can I get a visual sign of the Sundays?
  12. Hi There, I am working on a calendar, and I am with a problem. How could I know if the day is a sunday? Because I need to perform a sum of extra tax based on the weekday, and if it is Sunday it's applied extra tax. But for solving this post, print it as bold face is OK for me, because I have the Math already done, just need to get the sunday. Thanks in advance! Take a look at my working calendar <?php $monthNames = Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); if ( !isset( $_REQUEST["month"] ) ) { $_REQUEST["month"] = date("n" ); } if ( !isset( $_REQUEST["year"] ) ) { $_REQUEST["year"] = date("Y" ); } $cMonth = $_REQUEST["month"]; $cYear = $_REQUEST["year"]; $prev_year = $cYear; $next_year = $cYear; $prev_month = $cMonth-1; $next_month = $cMonth+1; if ( $prev_month == 0 ) { $prev_month = 12; $prev_year = $cYear - 1; } if ( $next_month == 13 ) { $next_month = 1; $next_year = $cYear + 1; } ?> <div class="container" > <div id="calendar_div" > <table> <tr align="center"> <td bgcolor="#999999" style="color:#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="50%" align="left"> <a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Anterior</a></td> <td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Próximo</a> </td> </tr> </table> </td> </tr> <tr> <td align="center"> <table border="0" cellpadding="2" cellspacing="2"> <tr align="center"> <td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong></td> </tr> <tr><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr> <?php $timestamp = mktime( 0, 0, 0, $cMonth, 1, $cYear ); $maxday = date( "t", $timestamp ); $thismonth = getdate( $timestamp ); $startday = $thismonth['wday']; for( $i=0; $i < ( $maxday+$startday ); $i++ ) { if( ( $i % 7 ) == 0 ) { echo "<tr>\n"; } if( $i < $startday ) { echo "<td></td>\n";} else { echo "<td align='center' valign='middle' height='20px;'>". ( $i - $startday + 1 ) . "</td>\n"; } if( ( $i % 7 ) == 6 ) { echo "</tr>\n"; } } ?> </table> </td> </tr></table> </div>
  13. Perfect! You solved my problem! It is exactly what I need! Thanks and yes, I in fact I will make the total field ready only.
  14. Hi, I am running across a situation. I have a script that dinamically creates fields to a list of products. I have 4 fields:PRODUCT, PRICE, QUANTITY and TOTAL The problems is: "How to multiply the product by the quantity for each array?" See below: <input name="price[]" /><input name="quantity[]" /><input name="total[]" /> Considering that I have created 3 items to my list: ??? #1 <input name="price[]" /><input name="quantity[]" /><input name="total[]" /> #2 <input name="price[]" /><input name="quantity[]" /><input name="total[]" /> #3 <input name="price[]" /><input name="quantity[]" /><input name="total[]" /> I don't realize how to calculate it! And the things get worst when thinking about calculating the total amount of totals for a final price <input name="total[]" /> + <input name="total[]" /> + <input name="total[]" /> Hope someone could help me about this mathematical problem, because I am not used to deal with calculations when programming. Thanks in advance!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.