Jump to content

kwstephenchan

Members
  • Posts

    64
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

kwstephenchan's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, I am sorry about the crumpsy title as I do not know how to put it. My problem is: I have a dependable dropdown list that help produce a list of states. But I want to select a particular state and change the information of that state, so I put an onChange event so that supposedly details of that state will be produced for modification. But the script is not answering the onChange event (have put an alert statement in the function and it is not showing it) I am totally new to Ajax and using this to learn, would someone please help point out what's wrong with it. Thanks in advance. The html are: <tr valign="baseline"> <td width="30%" align="right" class="lbtxt"><?php echo "Country : "; ?></td> <td><select name="m_country" onChange="getState(this.value)"> <option value=""><?php echo "Select Country"; ?></option> <?php mysql_select_db($database_conEstate, $conEstate); $cRS = mysql_query("SELECT * FROM country order by ".$lang."countryname asc") or die(mysql_error()); while ($crow = mysql_fetch_assoc($cRS)) { echo "<option value="; echo $crow['countryid']; echo ">"; echo $crow[$lang."countryname"]; echo "</option>"; } ?> </select> </td> </tr> <tr valign="baseline"> <td width="30%" align="right" class="lbtxt"><?php echo "State :"; ?></td> <td><div id="statediv"><select name="m_state" onChange="lookupstate('<?php echo $countryid; ?>','<?php echo $stateid;?>','<?php echo $showen; ?>','<?php echo $showbg; ?>','<?php echo $showgb;?>' );"> > <option><?php echo "Select Country First"; ?></option> </select></div> </td> </tr> The javascripts are: var urlstate = "lookupstate.php?param="; // The server-side script //alert{"here before lookupstate"); function lookupstate(countryid,stateid,showen,showbg,showgb) { alert("in lookupstate"); var http; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari http = new XMLHttpRequest(); } else { // code for IE6, IE5 http = new ActiveXObject("Microsoft.XMLHTTP"); } var id1=countryid; var id2=stateid; var showen=showen; var showbg=showbg; var showgb=showgb; // var showid=showid; var cid1 = document.getElementById(id1).value+","+document.getElementById(id2).value; alert("cid1="+cid1); http.open("POST", urlcountry + escape(cid), true); http.onreadystatechange = function() { try { if (http.readyState == 4 ) { // results = http.responseText; // document.getElementById(showen).value = results; results = http.responseText.split(","); document.getElementById(showen).value = results[0]; document.getElementById(showbg).value = results[1]; document.getElementById(showgb).value = results[2]; if (cid=="00") { document.getElementById(showen).value = ""; document.getElementById(showbg).value = ""; document.getElementById(showgb).value = ""; } else { // document.getElementById(showid).disabled=true; } } } catch(e){} } http.send(null); // http.onreadystatechange = handleHttpResponse; // http.send(null); }
  2. Just solved. I should be using POST instead of GET in my ajax calls.
  3. Hi, I have an ajax call to display the country name for update. After I change the data and press the updated button, (the data is updated to the database). But if I select the same country id (without leaving the page), it gives me the old data. Only if I leave the browser completely and call this ajax again, it then will give me the updated data. Don't know why can someone please advise what is causing the problem. The sequence of events are: 1. call out the country 2. update the country name 3. call out the country (here it is not showing the updated country name) But if I leave the browser completely, it will show me the updated country name Thanks.
  4. Hi, I have installed firefox, firebug, add firebug to firefox but I am still struggling to learn how to use firebug to debug. As I said, I did not see any error. The closest I got is the following : 错误: jsd is undefined 源文件:file:///C:/Documents%20and%20Settings/stephenchan/Application%20Data/Mozilla/Firefox/Profiles/cuutziqz.default/extensions/firebug@software.joehewitt.com/components/firebug-service.js 行:781 that is when I press ctrl+shift+j . I do not see how it is related to the program testajax nor the testajax.js . I may be asking too much, but could you copy the code I previously posted and see what you get. Those are all the codes that I have. Thanks a million.
  5. Hi, I was still not getting any error message except "error on page" at the bottom left of the brower. I was working on IE 7. I have trimmed down the code, basically what the following codes are doing is to open an URL object and send it and all the the url php program does is to display a few label (nothing shows up though). So I really don't know what have I done wrong. The following are all the codes I have, hope the trimming can help isolate the problem. By the way, I am completely new to both Javascript and Ajax and am really trying to learn it. It can be a very stupid mistake or I didn't quite grasp the concept. Thanks. Testajax.php <?php $editFormAction = $_SERVER['PHP_SELF']; ?> <html> <head> <title>Test Ajax</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <!-- Fireworks MX Dreamweaver MX target. Created Sat May 03 12:18:20 GMT+0800 (x_?DCRE?!) 2003--> <script src="testajax.js"></script> </head> <body bgcolor="#ffffff" link="#990000" vlink="#990000"> <table width="800" border="0" align="center" cellpadding="4" cellspacing="0"> <tr> <td> <form action="<?php echo $editFormAction; ?>" method="GET" name="form1" style="margin:0px;" > <table width="100%" border="0" cellspacing="0" cellpadding="1"> <tr valign="baseline"> <td width="40%" height="20" align="right" >Company ID : </td> <td id="main" height="20" > <input class="text" id="txtHint" type="text" size="20" > <button class="ebtn" onClick="showHint()">Hint</button> </td> </tr> </table> </td> </tr> </table> </body> </html> testajax.js var xmlHttp function showHint() { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="ajaxfindcompany.php"; // alert ("AJAX 01!"); url=url+"?sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; // alert ("AJAX 02!"); xmlHttp.open("GET",url,true); // alert ("AJAX 03!"); xmlHttp.send(null); // alert ("AJAX 04!"); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { alert ("Your browser does not support AJAX!"); // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } findajaxcompany.php <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <!-- Fireworks MX Dreamweaver MX target. Created Sat May 03 12:18:20 GMT+0800 (x_?DCRE?!) 2003--> <script language="JavaScript"> <!-- //--> </script> </head> <?php ?> <table width="800" border="0" align="center" cellpadding="4" cellspacing="0"> <tr valign="top"> <td width="800"> <table width="100%" border="0" cellspacing="4" cellpadding="0"> <tr valign="top"> <td> <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" > <tr> <td width ="80%" ><font color="#FFFFFF"><strong><font size="3"> Company</font></strong></td> </td> </tr> </table> <table width="98%" border="0" align="center" cellpadding="4" cellspacing="1"> <tr> <td> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr valign="baseline" > <td width="15%" align="center"><strong><font color="#FFFFFF" size="2">Company ID</font></strong></td> <td width="75%" align="center"><strong><font color="#FFFFFF" size="2">Company Name</font></strong></td> <td width="10%" height="16" align="center"><strong><font color="#FFFFFF" size="2"> </font></strong></td> </tr> </table></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body> </html>
  6. no explicit error message returned. The only clue is the "error on page" shown at the bottom left corner. I tried F12, nothing comes up. It is supposed to be a very simple ajax which opens a URL and send it. Have no clue what happened.
  7. Hi! I have the following php program : <start of program > <?php $editFormAction = $_SERVER['PHP_SELF']; ?> <html> <head> <title>Test Ajax</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <!-- Fireworks MX Dreamweaver MX target. Created Sat May 03 12:18:20 GMT+0800 (x_?DCRE?!) 2003--> <script src="testajax.js"></script> <LINK REL=STYLESHEET HREF="apponwebstyle.css" TYPE="text/css"> </head> <body bgcolor="#ffffff" link="#990000" vlink="#990000"> <table width="800" border="0" align="center" cellpadding="4" cellspacing="0"> <tr> <td> <form action="<?php echo $editFormAction; ?>" method="POST" name="form1" style="margin:0px;" > <table width="100%" border="0" cellspacing="0" cellpadding="1"> <tr valign="baseline"> <td width="40%" height="20" align="right" class="lgtxt">Company ID : </td> <td height="20" class="lgtxt"> <input class="text" id="comid" type="text" size="20" > <button class="ebtn" onClick="showHint()">Hint</button> </td> </tr> </table> </td> </tr> </table> </body> </html> <end of program> and an ajax script as follow : <start of ajax script> var xmlHttp function showHint() { /* if (str.length==0) { document.getElementById("comid").innerHTML=""; return; } */ xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="ajaxfindcompany.php"; url=url+"?sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("comid").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { alert ("Your browser does not support AJAX!"); // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } <end of ajax script> the js function "showHint" was executed alright until "xmlHttp.send(null);" it shows a message at the bottom saying error on page without loading the ajaxfindcompany.php program. Can someone help ?
  8. Hi, I have 1 php page (page 1) which has a button. On clicking of this button, another php page (page 2) will pop up with a list of values from the database. User will select one of these values and this value will be displayed on page 1. I know I must use ajax but don't know how. What I can do is to pass a value from page 1, through javascript (and a php which does not have user interface) get a value from the database and pass it back to page 1. What I am having trouble with is that the second page will have an interface for user to select. Just can't figure this out. Is there any suggestion or sample code that I can study. Thanks.
  9. Thanks for the advice. I am trying out what is suggested in the site. Although I have not solved the problem yet, I'll keep trying different scenario. Cheers.
  10. Hi, I have this program that searches the database and look for appropriate member and send a confirmation email to each one of them. In the email, I have a hyperlink to allow a reply to be sent back to me. My problem is that the hyperlink appears in a plain text in the email and is not clickable. I tried using the html tag <a href ... > </a> as well, it still does not work, instead, it displayed the html tag as well. Can someone help?
  11. What I am trying to do is to put the trailer informaton of each page into a common module and then calling this function from each page thus I do not need to go to every page to change if something has to be changed. The problem is that the characters are in Chinese. If I put these characters into the page without using the common module, it displays fine. But once I put them into the separate module, it displays funny characters. The following are the codes: The following codes are placed in a commomo module file called : module/common.php function trailer() { echo '<table width="800" border="0" align="center" cellpadding="1" cellspacing="1">'; echo '<tr height="20" colspan="5"><div> </div></tr>'; echo "<tr>"; $about="关于我们"; $about=mb_convert_encoding($about,"UTF-8"); echo '<div id="siteInfo"><font size="2"> <a href="aboutus.php">'.$about.'</a> | <a href="#">网站地图</a> | <a href="#">免责声明</a> | <a href="contactus.php">联系我们</a> </font></div>'; echo '</tr>'; echo '</table>'; } The following is the main program : <?php include ('module/common.php'); session_start(); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <?php trailer(); ?> </body> </html> can someone help?
  12. The error is: Mailer error: SMTP Error: Could not connect to SMTP host. But if I use another account, the mail will be sent. Don't know why.
  13. The following are my codes: I have defined this as a function and it is called by a main program. The problem : if I use the account abc.126.com, it works, if I used another one, it does not. The user id and password of another account are correct (I tested that). So I do not know why. By the way, I put the error_reporting(E_ALL), I am not getting any error message. code -- function smtp_mail ($subj,$body,$email,$name) { $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "smtp.126.com"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "abc"; // SMTP username $mail->Password = "abc254494"; // SMTP password $mail->From = "abc@126.com"; // sender email address $mail->FromName = "cs@abc"; // sender name $mail->CharSet = "GB2312"; // ! $mail->Encoding = "base64"; $mail->AddAddress($email,$name); // recipient email and name $mail->IsHTML(true); // send as HTML $mail->Subject = $subj; // $mail->Body = $body;// $mail->AltBody ="text/html"; $mail->Send(); } -- end code Thanks.
  14. Hi all, I tried sending email using phpmailer. It works for one account and it does not work for another. For example, if I use abc@126.com as sender to send out mail it works. But if use def@126.com as the sender, it does not send out the mail. To confirm the set up and password is correct, I tried sending the email from the 126 account instead of from the PHP program, it works. The smtp server I used is smtp.126.com. Is it possible that one account is attached to smtp.126.com and another account is attached to another smtp server, thus if I use smtp.126.com. it works for one account and it does not work for another. Is this possible?? Any one any hints?? Thanks.
  15. try to apply %LIKE% on both field not just one.
×
×
  • 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.