Jump to content

RichardRotterdam

Members
  • Posts

    1,509
  • Joined

  • Last visited

Everything posted by RichardRotterdam

  1. you said firebug gives the right output correct? what does the html form look like? does your form have this in it? <input type='text' name='poss_win' id='poss_win' value='' size='10' /> and what error do you get if you get one. another thing you never called the function stateChanged() try putting an alert inside it you will notice it doesnt do anything because it is never being called
  2. sorry man the getElementById was incorrect now it is correct document.getElementById('poss_win').value=xmlHttp.responseText;
  3. if that's the only thing then try function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById('poss_win').value=xmlHttp.responseText; } }
  4. I think mgallforever's code was a lot tidier to start with. but this will get you on the right track. first change your form like so(only added the id='stake)' <form method='post' action='some.php'> <input type='text' name='stake' id='stake' size='10' onkeyup='get_total()' /> <input type='text' name='poss_win' id='poss_win' value='' size='10' /> </form> then change your javascript to function get_total(){ /** *check browser for the correct xmlHttp request */ var http; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari http = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ http = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ http = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } /** *the url is the ajax page to be called in this case page.php *params are the values that are going to be send */ var url='page.php'; //get the value of the stake input element var stake=document.getElementById('stake').value; //get the value of the poss_win input element var poss_win=document.getElementById('poss_win').value; var params = 'stake='+stake+'&poss_win='+poss_win; http.open("POST",url, true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function(){ if(http.readyState == 4){ updateContent(http.responseText); } } http.send(params); } /** *this is the function that handles what is going to be updated on your main page */ function updateContent(text){ console.log(text);//this will output the data to firebug } read the comments i made in this script that will make things more clear on how it works
  5. I still think this should be moved to Ajax help. I know it was only to clarify you can use the get method and not to give a working example. @solon Maybe the info was a bit too much to start with I suggest you start some ajax tutorials or you could simply use a javascript framework to make things a lot easier. The code you posted is only html the interesting stuff happens in your get_total() function can you post that?
  6. did the gtk bundle installer not work? http://www.gtk.org/download-windows.html
  7. uhm isn't that already the solution? except for the return false which you don't need with the radiobutton
  8. I think you're looking for $_SERVER['SERVER_NAME']; you can just use the if statement to change the src attribute of the image
  9. Yes you can. However I am guessing you're not understanding the basics of ajax. You use javascript to make a call to an external file not php. for ajax you usually use 2 pages 1. the main page.(this can be a simple html file) 2. the ajax page/script.(usually a serverside script but can be a simple text file as well ) the main page makes a call to another page/script using javascript this main page can send values using the Get method or Post method for example var url='ajax_page.php?val1=first&val2=second'; this will send the values first and second. the ajax_page.php can return either plain text/html or json(which are javascript object) it can return xml too but hardly anyone does that these days. now for your solution you could use json to return 2 values which you then use to on your main page. as for the tiny bit that has to do with php. if youre using php 5.2 or above there is this handy function to transfrom a php array to json. this function is named json_encode good luck
  10. I don't have the answer you're looking for however the following framework could make things a lot easier for you http://morecss.yellowgreen.de/documentation/information/how-to-use/
  11. http://www.php.net/manual/en/
  12. here is a start for you javascript function showBoxes(value){ if(value==1){ //show boxes 1 and 2 }else if(value==2){ //show box 3 } } html <select onchange="showBoxes(this.value)"> <option value="1">1</option> <option value="2">2</option> </select>
  13. You could add the id attribute to the images thats how the getElementById() function works example document.getElementById('image1').src="new_image.jpg" would change the image <img id='image1' src='old_image' />
  14. I think hiding the element would be like so window.addEvent('domready', function(){ var slide1 = new Fx.Slide('myContent').hide(); //initialize and set to hidden initially $('button1').addEvent('click', function(e){ // set the click event of the link to toggle slide1 e = new Event(e).stop(); //prevent native click event slide1.hide();//this is where you hide it }); });
  15. do you mean something like this? http://demos.mootools.net/Fx.Slide
  16. it wasn't a year old since the last post. old yea but....... sorry next time i'll read more carefully on the messages
  17. you won't really notice the performance difference. but setting up tomcat can take a lot of time though
  18. why not just include that file?
  19. Starting with JS can be a bit of a pain in the butt . But here is some hints to get you on your way. first get firefox with the firebug plugin. it gives friendly error messages to make javascripting a whole lot easier. after that just do your basic things like if statements for loops etc. Then you want to look into javascript DOM(Document Object model) most stuff you see on the web these days relies on DOM and if you get the hang of that you might wanna look into frameworks such as jQuery,prototype and mootools
  20. the correct way on using a select element is using the onchange <select onchange="js_function(this.value)"> </select> the this.value will pass the value to the function i think that will do the trick
  21. just to help you a bit on your way the following code tr.style.display = 'none'; does the following <tr style="display:none"></tr> it sets the style to do the reverse you could remove the style attribute oh and one thing this function function poorman_toggle(id) { var tr = document.getElementById(id); if (tr==null) { return; } var bExpand = tr.style.display == ''; tr.style.display = (bExpand ? 'none' : ''); } the bExpand boolean has no value in the function so it will always set the style.display='none'
  22. I remember a teacher that explained the speed of webscripting languages once and saying which one was better. what a terrible teacher that was. only speed you might want to be bothered with is development time (unrelated to the language btw)
  23. just to be sure I need to ask you. you do know that php is serverside(runs on the server computer) and javascript is clientside(runs in browser) right? so this line in your code If ($JOBTYPE == "0") $JOBQRY = ($jobselect0); this will simply put $JOBTYPE in your javascript and not a usable value (off topic but the If should be with undercaps if) if you would write If (<?php echo $JOBTYPE ?>== "0") <?php echo $JOBQRY ?> = (<?php echo$jobselect0 ?>); that would be different
  24. you could use ajax to read the text file. check out a some ajax tutorial or easier just use some javascript framework to make it easier
  25. PDO maybe? its comes as part of php since version 5
×
×
  • 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.