Jump to content

darantes

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

darantes's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sure, in your INPUT tag you set MAX=(any value) and the tag itself limits the character number.
  2. Hi, If I understood what you wish, you simply have to put an [b]onKeyUp [/b]event in your input tag. This onkeyUp event has to call a java script function that changes the width of the input field like this: [!--coloro:#3333FF--][span style=\"color:#3333FF\"][!--/coloro--]onKeyUp='changeWidth(this)'[!--colorc--][/span][!--/colorc--] function changeWidth(obj) { obj.style.width = obj.value.length * (any constant here) } where obj is the input field passed as parameter into the onKeyUp event as [!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--]this[!--colorc--][/span][!--/colorc--]. the constant is any value (in pixels) that multiplies the length of the input field value to make the width of the field looks good ;) I hope it helps, good luck Diogo
  3. Hi all ! Let me see if anyone can help me with that. I spent hours and hours on this, but in the end, I abandoned cause I really think this has no solution. The whole thing is: * I have a login page; * I enter my username and password and click Login; * An ajax request queries the database to validate my login; * I receive the request response and, at this point, I deny the login or I grant it. * When granting the login, I call the next page and everything is ok, [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]unless if you want to send some variables to the next page.[!--colorc--][/span][!--/colorc--] [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]This is my blocking point[!--colorc--][/span][!--/colorc--]. The next page that is called when the login is well done I will need the user name, id, email, etc... My question is: How to send variables through POST or GET without submiting a form and thus reloading the page ? I tried to make another Ajax request to my next page, but it definitely makes no sense ! Also I thought using cookies would easily solve my problem, but I don't like the idea regarding that many users have cookies disabled on their browsers. I know it is possible to do because I see Gmail working like that ! But even tracking its login page java script source code, I didn't find out how they do it. One can say it is worthless because all this work will only prevent the page from reloading, and instead I could submit the form, but here my aim is to turn the pages every time more dynamic using new technologies and surely, giving the web a more beautiful look ;) Anyone have any idea ?
  4. Thanks for testing... but I forgot to mention something that can be the reason of why it worked for you. I am using Mozilla Firefox and it for some strange reason worked sometimes. I noticed it worked when we had a delay between the call of the two Ajax function (when I put an Alert when receiving the response of the first request). On Internet Explorer it seemed to work almost the time, but it failled sometimes... I think it is something the browser can not handle or the use of two ajax requests in cascade was not take in account when the project of the browser. Thank you!! [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]
  5. Hi ! I am developing a web application that requires me to send mails through ajax. The main problem I found is that I am trying to call my sendmail function written in javascript into an existing ajax request. I will explain directly with the real code. [!--coloro:#3366FF--][span style=\"color:#3366FF\"][!--/coloro--](An onclick event calls this function) [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]function updateDB() { http.open('post', 'DBtasks.php'); http.onreadystatechange = verifyUpdateTable; http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.send('action=3&id='+trip_id+'& MY DATA'); } function verifyUpdateTable() { if( http.readyState == 4 ) { if( http.status == "200" ) { var res = http.responseText; if (res == '1') { msg = 'test'; sendMail('myMail', 'my subj', 'my msg'); // so I am calling sendMail into this function that belongs to an ajax request } } } }[!--fontc--][/span][!--/fontc--] [!--colorc--][/span][!--/colorc--] [!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--](file: functions.js) [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]var httpMail = createRequestObject(); // this is ok,, do not worry about it function sendMail(to, subject, message) { httpMail.open('post', 'sendMail.php', true); httpMail.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); httpMail.send('to='+to+'&subject='+subject+'&message='+message); httpMail.onreadystatechange = verifySent; } function verifySent() { if( httpMail.readyState==4 ) { alert(httpMail.status); // this alert shows an EMPTY STRING as the status and never goes into the next if if( httpMail.status==200 ) { var resp = httpMail.responseText; alert(resp); } else { //displayMsg('Failed to send mail\n'+httpMail.statusText); } } }[!--fontc--][/span][!--/fontc--] [!--colorc--][/span][!--/colorc--] [!--coloro:#993399--][span style=\"color:#993399\"][!--/coloro--](file: sendMail.php) [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]<?php $to=$_POST['to']; $subject=$_POST['subject']; $message=$_POST['message']; $headers="Content-Type: text/plain; charset=iso-8859-1\n". "From: atf@idh.com\n". "Reply-to: atf@idh.com\n\n"; if(!mail($to,$subject,$message,$headers)){ echo 'NOK'; } else{ echo 'OK'; } return ?>[!--fontc--][/span][!--/fontc--] [!--colorc--][/span][!--/colorc--] [u]The results[/u]: Once I make a test with this code I have no mail sent. IF I try to call the sendMail javascript function out of the first ajax function ( verifyUpdateTable) it works perfectly. So my issue really lays on the fact that I am calling the sendMail function into my first ajax verification function. Anyone knows if it is possible to be this way ? otherwise, how could I send an email after updating my DB using ajax ? I cannot do it directly in PHP because the contents of my mail depends on the database update results. Anyone has any suggestion ??? [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] [!--coloro:#CCCCCC--][span style=\"color:#CCCCCC\"][!--/coloro--] [!--colorc--][/span][!--/colorc--]
×
×
  • 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.