Jump to content

scott100

Members
  • Posts

    1,819
  • Joined

  • Last visited

Everything posted by scott100

  1. scott100

    PHP Syntax

    One problem at a time, have a look at this for client side calculations.I have coloured the sections that i have added to make it clearer. The javascript function goes in the head and the php in the body. The form is checked with an onclick handler and i have created an extra div to display the total.<html>[color="red"]<head><script>[color="blue"]function check(){[/color]var tot=0; if (document.myForm.box1.checked) {tot+=35;} if (document.myForm.box2.checked) {tot+=40;} if (document.myForm.box3.checked) {tot+=45;} [color="green"]document.getElementById('t1').innerHTML="$"+tot;[/color]}</script></head>[/color]<body><?php$total1=0;if ( isset ($_POST['submit'])) {$box1= $_POST['box1']; $box2= $_POST['box2']; $box3= $_POST['box3'];if ($box1 == "y") {$total1+=35.00;}if ($box2 == "y") {$total1+=40.00;}if ($box3 == "y") {$total1+=45.00;}print"Your total is $$total1";} // End of handle form IF.else {form();// Display the form.}function form(){print'<form [color="red"]name="myForm"[/color] action="22.php" method="post" [color="blue"]onclick="java script:check()"[/color]>Bread: <input type="checkbox" name="box1" value="y" /> <br />Milk: <input type="checkbox" name="box2" value="y" /><br />Cheese: <input type="checkbox" name="box3" value="y" /><br /><br /><input type="submit" value="submit" name="submit" /><br /><br />[color="green"]<div>Total: <span id="t1"></span></div>[/color]';}?></body> Did you follow that ok?
  2. I kept getting an access denied error when trying to use it. :)EDIT - It's ok it works now.
  3. You would be directed to the second form and only form2 would actually be processed (i think - i done alert() tests and thats what i found)To get round this you could target each form to an iframe which doesn't require you to leave the current page.I have make a javascript test to show that both forms are processed.http://scott100.atspace.com/test.htmAs you can see from the results, when you type in different usernames both forms are processed.
  4. one way:<table><tr><td onmouseover="this.bgColor='green'" onmouseout="this.bgColor='white'" >asdf</td></tr></table>
  5. scott100

    PHP Syntax

    Do you mean as the user checks a box on the client side you want the total to be updated and display, combining it with the email should be easy, just print it out to the body
  6. Yeah although dom is a w3 recommendation, innerHTML is supported by most/all browsers and is faster.If i was writing to the body with innerHTML i would also write to a div in the body, not the body its self
  7. You could use DOMSee this page for example to make a table with domhttp://developer.mozilla.org/en/docs/Trave..._DOM_Interfaces
  8. This will stop the content.<script type="text/javascript">/************************************************ Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)* This notice MUST stay intact for legal use* Visit Dynamic Drive at [url="http://www.dynamicdrive.com/"]http://www.dynamicdrive.com/[/url] for full source code***********************************************/var delay = 2000; //set delay between message change (in miliseconds)var maxsteps=30; // number of steps to take to change from start color to endcolorvar stepdelay=40; // time in miliseconds of a single step//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effectvar startcolor= new Array(255,255,255); // start color (red, green, blue)var endcolor=new Array(0,0,0); // end color (red, green, blue)var fcontent=new Array();begintag='<div style="font: normal 14px Arial; padding: 5px;">'; //set opening tag, such as font declarationsfcontent[0]="<b>What\'s new?</b><br>New scripts added to the Scroller category!<br><br>The MoreZone has been updated. <a href='../morezone/index.htm'>Click here to visit</a>";fcontent[1]="Dynamic Drive has been featured on Jars as a top 5% resource, and About.com as a recommended DHTML destination.";fcontent[2]="Ok, enough with these pointless messages. You get the idea behind this script.</a>";closetag='</div>';var fwidth='150px'; //set scroller widthvar fheight='150px'; //set scroller heightvar fadelinks=1; //should links inside scroller content also fade like text? 0 for no, 1 for yes.///No need to edit below this line/////////////////var ie4=document.all&&!document.getElementById;var DOM2=document.getElementById;var faderdelay=0;var index=0;/*Rafael Raposo edited function*///function to change contentfunction changecontent(){ if (index>=fcontent.length) index=0 if (DOM2){ document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")" document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag if (fadelinks) linkcolorchange(1); colorfade(1, 15); } else if (ie4) document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag; index++}// colorfade() partially by Marcio Galli for Netscape Communications. ////////////// Modified by Dynamicdrive.comfunction linkcolorchange(step){ var obj=document.getElementById("fscroller").getElementsByTagName("A"); if (obj.length>0){ for (i=0;i<obj.length;i++) obj[i].style.color=getstepcolor(step); }}/*Rafael Raposo edited function*/var fadecounter;function colorfade(step) { if(step<=maxsteps) { document.getElementById("fscroller").style.color=getstepcolor(step); if (fadelinks) linkcolorchange(step); step++; fadecounter=setTimeout("colorfade("+step+")",stepdelay); }else{ clearTimeout(fadecounter); document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")"; setTimeout("changecontent()", delay); } }/*Rafael Raposo's new function*/function getstepcolor(step) { var diff var newcolor=new Array(3); for(var i=0;i<3;i++) { diff = (startcolor[i]-endcolor[i]); if(diff > 0) { newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step); } else { newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step); } } return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");}if (ie4||DOM2) document.write('<div onmouseover="clearTimeout(fadecounter)" id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>');if (window.addEventListener)window.addEventListener("load", changecontent, false)else if (window.attachEvent)window.attachEvent("onload", changecontent)else if (document.getElementById)window.onload=changecontent</script> The only problem is starting it again, if you try onmouseout="changecontent()" the whole thing flickers and goes nuts
  9. scott100

    Check the user's IP

    <?PHP$ipaddress = $_SERVER["REMOTE_ADDR"];Echo "Your IP is $ipaddress!";?>
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head><title>Basic XHTML Document Structure</title></head><body><p>Hello World from an XHTML File.</p></body></html> This Page Is Valid XHTML 1.0 Strict!
  11. scott100

    javascript help

    That wont work because you are trying to call asp code on the client sideWhat you would need to do is print the value from the cookie to a javascript variable when the code is generated at the server.Something like this:<% response.write "<script> var asp=\"" & Request.Cookies('id')& "\"\; x.innerHTML=asp</script>" %>
  12. Yes it can be done, if you give your forms a name then you can submit both with javascript.The javascriptfunction submitForms() {document.[color="red"]form1[/color].submit();document.[color="blue"]form2[/color].submit();} The forms <form action="sectest2.asp" method="post" name="[color="red"]form1[/color]">...</form><form action="sectest2.asp" method="post" name="[color="blue"]form2[/color]">...<input type="button" value="submit" onclick="submitForms()" /></form>
  13. setTimeOut would do it, but i think the meta tag is better choice
  14. Maybe this one will be better for you, it does everything you asked for http://www.dynamicdrive.com/dynamicindex2/crosstick.htm
  15. scott100

    PHP Syntax

    No probs any questions with the logic just ask
  16. scott100

    PHP Syntax

    What's the problem this is very straight forward, only a couple of extra lines were required from what i gave earlier.it displays fine when $total1=0;Here is the full code. save as 22.php <?php$total1=0;if ( isset ($_POST['submit'])) {$box1= $_POST['box1']; $box2= $_POST['box2']; $box3= $_POST['box3'];if ($box1 == "y") {$total1+=35.00;}if ($box2 == "y") {$total1+=40.00;}if ($box3 == "y") {$total1+=45.00;}print"Your total is $$total1";} // End of handle form IF.else {form();// Display the form.}function form(){print'<form action="22.php" method="post"><input type="checkbox" name="box1" value="y" /> <input type="checkbox" name="box2" value="y" /><input type="checkbox" name="box3" value="y" /><input type="submit" value="submit" name="submit" />';}?>
  17. scott100

    PHP Syntax

    The php should look like this $box1= $_POST['box1']; $box2= $_POST['box2']; $box3= $_POST['box3'];if ($box1 == "y") {$total1+=35.00;}if ($box2 == "y") {$total1+=40.00;}if ($box3 == "y") {$total1+=45.00;} And the html inputs should look like this <input type="checkbox" name="box1" value="y" /> <input type="checkbox" name="box2" value="y" /><input type="checkbox" name="box3" value="y" />
  18. Yeah i tried it.You will find this line of code in the script document.write('<div id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>'); Add this bit in red to that code and it will halt the show document.write('<div onmouseover="clearTimeout(fadecounter)" id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>');
  19. Add the bit in red. document.write('<div onmouseover="clearTimeout(fadecounter)" id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>');
  20. scott100

    Data Island

    1) span is a container for the results, in order to bind this data to HTML elements, you must specify the DATASRC and DATAFLD attributes on those elements.2) The "#" preceding the XML data island ID in the DATASRC attribute must be present in order to bind the data. The hash (#) sign usually means get the element by it's id so there should be an element on the page with id="cdcat" - which there is.
  21. You could use something like this.http://www.dynamicdrive.com/dynamicindex2/fadescroll.htmthen use a clearTimeout() on mouseover to halt
  22. instead of innerhtml: http://javascript.internet.com/forms/addin...l-controls.html
  23. Here's a good site on rounded cornershttp://www.cssplay.co.uk/boxes/snazzy.htmlhttp://www.cssplay.co.uk/boxes/krazy.html
  24. Firefox is a web broswer, superior to Internet ExplorerDownload your copy for free here: http://www.mozilla.com/firefox/
  25. Yeah these guys didn't want anyone getting these videos.I spent 10mins trying to trace different paths and came up against a brick wall. They are calling things breadcrumb - i think i followed the wrong ones :)If you can play a video then it's possible to download it, the problem is finding it's path
×
×
  • Create New...