Jump to content

justinh

Members
  • Posts

    246
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

justinh's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. allright I fixed it somehow function updateCountry(){ var region = document.getElementById("region"); var regionsel= region.options[region.selectedIndex].value; var url = 'http://cwwebapps.craneww.com/Agents/templates/testings.pl?region=' + regionsel; var myAjax = new Ajax.Request( url, { method: 'get', onSuccess: function(transport){ var countries = transport.responseText; var singlecountry = countries.split("|"); singlecountry.pop(); var select = document.forms.addentry.elements.country; select.options.length = 1; for(i=0;i<singlecountry.length;i++){ select.options[select.options.length] = new Option(singlecountry[i], singlecountry[i]);. } }}); }
  2. Hey I'm trying to add an option to a select with Ajax. My code works fine in IE, but does not work in Firefox. I was going to post this in the AJAX section, but I'm pretty sure the problem is not AJAX, but is the way I'm going about adding an option to the select. I've tried pretty much everything I saw when looking the problem up on google. But still nothing. =( Here's the code in question function updateCountry(){ var region = document.getElementById("region"); var regionsel= region.options[region.selectedIndex].value; var url = 'http://cwwebapps.craneww.com/Agents/templates/testings.pl?region=' + regionsel; var myAjax = new Ajax.Request( url, { method: 'get' onSuccess: function(transport){ var countries = transport.responseText; var singlecountry = countries.split('|'); singlecountry.pop(); var theSelectList =$('country'); var select = document.forms.addentry.elements.country; theSelectList.options.length = 1; for(i=0;i<singlecountry.length;i++){ select.options[select.options.length] = new Option(singlecountry[i], singlecountry[i]); } }}); } You can see, http://cwwebapps.craneww.com/Agents/index2.pl?display=add_entry .. works in Internet Explorer, but no Firefox. Any help would greatly be appreciated. Thanks
  3. Okay I'm trying to write some ajax that updates dropdownmenu B based on what is selected in dropdownmenu A. I found a tutorial and tried my best to follow it, but I'm not the one to just copy and paste something and call it done, I like to understand how it works. Heres the code from the form page. <html> <head> <script type="text/JavaScript"> var xmlHttp; function createXMLHttpRequest(){ if (window.ActiveXObject){ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest){ xmlHttp = new XMLHttpRequest(); } } function doIt(dd1) { var idx = dd1.selectedIndex; var val = dd1[idx].text; var par = document.forms["addentry"]; var parelmts = par.elements; var varcountry = parelmts["country"]; createXMLHttpRequest(); xmlHttp.onreadystatechange = handleStateChange(varcountry); xmlHttp.open("GET", "/Agents/templates/testings.pl?region=" + val , true); xmlHttp.send(null); } function handleStateChange(countryelmt){ if (xmlHttp.readyState == 4){ if(xmlHttp.status == 200){ var countri = xmlHttp.responseText; var countries = countri.split("|"); countryelmt.length = 1; countryelmt.length = countries.length; for(o=1; o < countries.length; o++){ countryelmt[o].text = countries[o]; } } } } </script> </head> <div id="content"> <p class="contentheader">Add Entry</p> <div id="content"> <div id="spitout"></div> <form name="addentry" id="addentry" method="POST" action="http://www.cwwebapps.craneww.com/Agents/index2.pl?display=add_entry&insert=1"> <Fieldset> <legend>Add Entry</legend> <ol><li> <label for="entrytype">Entry Type</label> <select name="entrytype"> <option value="gln">GLN</option> <option value="agent">Agent</option> <option value="crane">Crane</option> </select></li> <li> <label for="region">Region</label> <select name="region" onchange="doIt(this);"> <option value="">Select Region</option> <option value="EMEA">EMEA</option> <option value="LATAM">LATAM</option> <option value="ASPAC">ASPAC</option> <option value="NORTAM">NORTAM</option> <option value="CENTAM">CENTAM</option> </select> </li> <li> <label for="country">Country</label><select name="country"> <option value="">Select Country</option> </select> </li> </ol> </fieldset> <fieldset class="submit"> <input class="submit" type="submit" value="Add"> </fieldset> </form> and heres the code to testings.pl ( the page the ajax calls to) #!/usr/bin/perl -w use strict; use CGI; use DBI;. my $cgi = CGI->new(); print $cgi->header(); my $region = $cgi->param('region'); my $dbh = DBConnect(); my $query = "SELECT DISTINCT country from stations WHERE region =\"". $region."\""; my $sth = $dbh->prepare($query); $sth->execute(); while( my $ref = $sth->fetchrow_hashref()){ print $ref->{country}."|"; } sub DBConnect { my $db = shift || "agent_info"; my $dn = "DBI:mysql:$db"; my $dbh = DBI->connect($dn, "*****", "******") or die("Error connecting to Database:" . $DBI::errstr); } Now I have tested just the xmlHttp.responseText to see if its the output not coming out right, but it prints out just fine every time i change the dropdownmenu A. So that's working, just can't get it to add into dropdownmenu B. Any help would be greatly appreciated. Thanks
  4. Noted sir. Thanks for your insight and helpfulness, I appreciate it.
  5. So you're saying you LIKE it when people find vulnerabilities in other people's code, and exploit it? I don't quit understand your reply.
  6. Oh your right! So in a perfect world this would be fine. But we have people that do mean things
  7. I was wondering if you guys could tell me if this is an okay way to go about loading different pages. index.php <?php isset($_GET['page']) ? $page = $_GET['page'] : $page = "main"; include($page.".php"); ?> And I would keep the pages in the same directory as index.php
  8. What is assigned to the 'url' variable?
  9. Thanks for the critique!! I will fix these problems A.S.A.P I also had mix feelings on the background
  10. Trying to come up with a design for my portfolio. How does this look to you? Constructive criticism is greatly appreciated. http://wmptest.com/testing/design/
  11. Found something out, If I have 2 clients in the hrclienta with cl_partycontact set to y, it displays each of them 2 times. If I have 3 clients in the hrclienta with cl_partycontact set to y, it displays each of them 3 times.. etc.. Any ideas why? Thanks, justin
  12. <?php $query = " SELECT hrclienta.cl_firstname, hrclienta.cl_lastname, hrhunts.dateofhunt, hrhunts.totalcost, hrhunts.paidstatus FROM hrclienta, hrhunts WHERE (hrclienta.cl_partyid = hrhunts.huntid AND hrclienta.cl_partycontact = 'y')"; $doit = mysql_query($query) or die(mysql_error()); echo "<table width=\"400\" cellpadding=\"20\"><tr><td>Name</td><td>Date Of Hunt</td><td>Total Cost</td><td>Deposit Required</td><td>Paid Status</td></tr>"; while($viewreservation = mysql_fetch_array($doit)){ $deposit = number_format($viewreservation['totalcost'], 2, '.', '') / 2; echo "<tr><td>".$viewreservation['cl_firstname']." ".$viewreservation['cl_lastname']."</td><td>".$viewreservation['dateofhunt']."</td><td>". $viewreservation['totalcost']."</td><td>".$deposit."</td><td>"; if($viewreservation['paidstatus'] == "y"){ echo "<input type=\"button\" value=\"Paid\" class=\"paid\"></td></tr>"; }else{ echo "<input type=\"button\" value=\"Not Paid\" class=\"notpaid\"></td></tr>"; } } echo "</table>"; ?> This code works how I want it to if there is only one client in hrclienta with cl.partycontact set to y but when I add a second one, it displays each row twice =/ Any idea why this would happen?
  13. even before session_start() ?
  14. this is the entire code, was trying to not post the whole thing because I know how you guys don't like this. <?php session_start(); include("connect.php"); if(isset($_SESSION['loggedin'])){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The New Rev-FM 94.3</title> <link href="css/login.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <link href="p7vscroller/s5/p7VSC05.css" rel="stylesheet" type="text/css" media="all" /> <script type="text/javascript" src="p7vscroller/p7vscscripts.js"></script> <script type="text/javascript" language="JavaScript1.2" src="stmenu.js"></script> </head> <body onload="MM_preloadImages('css/images/listenliveovr.png','css/images/surgery.png','css/images/fostercharitable.png')"> <div id="container"> <div id="topcontent"> </div> <div id="contentbg"> <div id="menubg"> <div id="menu"> <script type="text/javascript" language="JavaScript1.2"> <!-- stm_bm(["menu5574",730,"","blank.gif",0,"","",1,0,250,0,1000,1,0,0,"","900",0,0,1,2,"default","hand",""],this); stm_bp("p0",[0,4,0,0,0,7,5,0,100,"",-2,"",-2,50,0,0,"#999999","transparent","bg_01.gif",3,1,1,"#000000"]); stm_ai("p0i0",[0,"Home","","",-1,-1,0,"index.html","_self","","","","",5,5,0,"","",0,0,0,1,1,"#FFFFF7",1,"#993333",1,"","bg_02.gif",3,1,0,0,"#FFFFF7","#000000","#FFFFFF","#FFFFFF","bold 9pt Arial","bold 9pt Arial",0,0]); stm_aix("p0i1","p0i0",[0,"Jocks","","",-1,-1,0,"jocks.html","_self","","","","",5,5,0,"","",-1,-1]); stm_bpx("p1","p0",[1,4,0,2,0,5,0,0,80,"progid:DXImageTransform.Microsoft.RandomDissolve(,enabled=0,Duration=0.30)",12,"progid:DXImageTransform.Microsoft.RandomDissolve(,enabled=0,Duration=0.30)",12,80,0,0,"#666666","#000000",""]); stm_aix("p1i0","p0i0",[0,"Dave Dodson","","",-1,-1,0,"daved.html","_self","","","","",0,0,0,"","",0,0,0,0,1,"#F9E0CA",1,"#666666",0,"","",3,1,0,0,"#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","9pt Arial","9pt Arial"]); stm_aix("p1i1","p1i0",[0,"Natalie Steele","","",-1,-1,0,"steele.html"]); stm_aix("p1i2","p1i0",[0,"Justin Tenery","","",-1,-1,0,"jt.html"]); stm_aix("p1i3","p1i0",[0,"Tommy Jenkins","","",-1,-1,0,"bone.html"]); stm_aix("p1i4","p1i0",[0,"Danny Del Rossi","","",-1,-1,0,"ddrossi.html"]); stm_aix("p1i5","p1i0",[0,"Big G","","",-1,-1,0,"bigg.html"]); stm_ep(); stm_aix("p0i2","p0i0",[0,"Contests","","",-1,-1,0,"promos.html","_self","","","","",5,5,0,"","",0,0,0,1,1,"#FFFFF7",1,"#993333",1,"","bg_02.gif",3,1,0,0,"#FFFFF7","#000000","#FFFFFF","#FFFFFF","bold 9pt 'Arial','Verdana'"]); stm_aix("p0i3","p0i0",[0,"Events","","",-1,-1,0,"","_self","","","","",5,5,0,"","",-1,-1,0,1,1,"#FFFFF7",1,"#993333",1,"","bg_02.gif",1]); stm_bpx("p2","p1",[]); stm_aix("p2i0","p1i0",[0,"Concerts","","",-1,-1,0,"concerts.html"]); stm_aix("p2i1","p1i0",[0,"Community Calendar","","",-1,-1,0,"calendar.html"]); stm_ep(); stm_aix("p0i4","p0i3",[0,"Media"]); stm_bpx("p3","p1",[]); stm_aix("p3i0","p1i0",[0,"Photo Gallery","","",-1,-1,0,"photos.html"]); stm_aix("p3i1","p1i0",[0,"Video","","",-1,-1,0,"video.html"]); stm_ep(); stm_aix("p0i5","p0i3",[0,"Advertising"]); stm_bpx("p4","p1",[]); stm_aix("p4i0","p1i0",[0,"Media Kit","","",-1,-1,0,"kit.html"]); stm_aix("p4i1","p1i0",[0,"Staff Login","","",-1,-1,0,"staff.php"]); stm_aix("p4i2","p1i0",[0,"Remotes","","",-1,-1,0,"remotes.html"]); stm_aix("p4i3","p1i0",[0,"Contact Sales Staff","","",-1,-1,0,"contact.html"]); stm_ep(); stm_ep(); stm_em(); //--> </script> </div> </div> <div id="content1"> <br><br></br></br><br><br></br></br> <div id="login"> Welcome to the media Kit!! </div> </div> </div> </div> <div id="botcontent"> </div> <div id="footer"> <a href="index.html">HOME |</a> <a href="jocks.html">JOCKS |</a> <a href="promos.html">CONTESTS |</a><br /> <br /> <a href="links.html">Link Us</a> <a href="ads.html">Advertising</a> <a href="policy.html">Privacy Policy</a> </div> </div> </body> </html> <?php } else { if(isset($_POST['login'])){ $username = $_POST['accountname']; $password = $_POST['password']; $query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'"; $check = mysql_query($query) or die(mysql_error()); $num = mysql_num_rows($check); if($num == 1){ $_SESSION['loggedin'] = 1; echo "logged in!"; } else { echo "error"; } }else{ echo "You must log in to view this page."; } ?>
×
×
  • 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.