Jump to content

ajoo

Members
  • Posts

    871
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by ajoo

  1. Thanks guys !

    @ kicken: Thanks loads. I couldn't have spotted it in 10 days at least. The previous ten bear testimony to that !😲

    @ requinix: Thanks for that tip ! I'll bear it in mind. 

     

  2. hi ,

    please can someone check the fiddle https://jsfiddle.net/yqktb40L/18/ and say why the block remains stuck in its position and not oscillate up n down every 2 seconds as it is supposed to. 

    There is nothing wrong with the code. It works great on a local server but does not work in jsfiddle. 

    Thank you. 

  3. Hi all !

    This following code works but 

    HTML:

    <button class="" id="listen">Play Audio</button>

    JS:

    $(document).ready(function(){
    	$('#listen').click(function(e){
    
    	var url = "https://hpr.dogphilosophy.net/test/wav.wav";
    	var audio = new Audio(url);
    
    	audio.type = 'audio/wav';
    	audio.play();
    	});
    });

    but only if there is some interaction like the button click on the document first. I would like to get the sounds to play without any interacting controls. Isn't that possible ?

    Any help appreciated, 

    Thanks !

  4. Hi denno, 

    You are correct about the audio.load. So i modified as follows and was quite hopeful that it would work but it still doesn't 

    	var url = "music/beep-07.wav";
    	var audio = new Audio(url);
    	
    	audio.addEventListener("loadeddata", function() {
    	  audio.play();
    	}, true);

    It gives 

    Quote

    Uncaught (in promise) DOMException

    this error message though I wonder why because this is the error given by the play() function if you play() the audio directly while it is still loading. Here it is inside the "loadeddata" event handler so the data should have loaded before play() was called.

    Still at it.

    Thanks !

     

     

     

  5. Hi !

    I have been trying to play sounds using this tiny snippet which gives no errors or warnings but the sounds won't play. 

    	var url = "https://hpr.dogphilosophy.net/test/wav.wav";
    	var audio = new Audio(url);
    	audio.load();
    
    	audio.addEventListener("load", function() {
    	  audio.play();
    	}, true);

    I have checked the sound link and it works directly in the browser. 

    Can someone please help. 

    Thanks. 

  6. Thanks kicken ! for this alternate method. I do not fully understand it, but i'll look it up and if need be reopen this thread again. For the time being I have used the hidden field method suggested by Guru Barand !

    Thanks loads !

  7. Hi Guru Barand, 

    For an HTML form that is not echoed out in php, the $value variable is checked that it exists, before it is echoed out.

    value="<?php if(isset($value)) echo html_escape($value);?>"

     

    How Is it possible to do the same here ?

    echo "<td> <input type='text' name='reply[]'class="ansbox" value='$value'></td>";

     I have tried without success. 

    Thanks.

  8. Hi, 

    I have another but related question, so I will continue it here rather than in a new thread. I hope that is ok.

    SO if I modify my code as shown by Kicken like below:-

    <?php 
    
    $count = 10;
    echo "<tr>";
      for($j=0; $j<$count; $j++)
      {
         echo "<td> <input type='text' name='reply[]'class="ansbox" value=''></td>";
      }	
    echo "</tr>";
    ?>

    and once the form has submitted the 10 post values, how can I print those back into their respective places using PHP not JS. I know it will have to echo them inside their value ' ' fields, having checked first if they have been set using isset( .. ), but I don't know the correct syntax to achieve that. 

    Thanks all !

     

  9. Hi Kicken !

    Thanks for the reply and for introducing me to the correct usage ! Even though  I am getting the correct answer by using an array for both names and id's and then targeting the id to get the values of the array in JS, getting to know the correct form is so essential. 

    Thanks loads for the correction !

     

     

  10. Hi all, 

    This bit of code creates an array of input fields using php:-

    .
    .
    .
    $count = 10;
    echo "<tr>";
      for($j=0; $j<$count; $j++)
      {
         echo "<td class=userinp> <input type='text' id='reply[]' value='' ></td>";
      }	
    echo "</tr>";
    .
    .                       
                        

    I wish to process the values entered in the input fields using JQuery. How can I fetch these user inputs into JQuery correctly ?

    My JQuery code is :

    		$("#checkbutton").click(function(){
    			var test_arr = $("input#reply");
    			$.each(test_arr, function(i, item) {
    				val = $(item).val();
    				alert(i+" : "+ val);
    			});
    		});

    which displays only the first value of the user input box. It is thus not fetching the array . Please point out the mistake or the correct method to achieve this.

    Thanks !

     

     

     

  11. Thank you Guru Barand !

    While the above works fine when the js is enclosed in <script> tags and appended to the php file, it fails when the JS code is included as a separate js file. 

    I guess the only way it works when the JS code is in its own file is as indicated by you, using a hidden field ! 

    Thank you very much ! 

  12. Hi all !

    This following code is supposed to pass an array from php to js:-

    $( document ).ready(function(){
    	alert('Yo');
    	var rs = <?php echo json_encode($rs);?>;
    	alert(rs);
    });

    instead javascript gives an error as 

    Quote

    testsums.js:3 Uncaught SyntaxError: Unexpected token <

    Here's the simple php code as well:

    <?php 
    	$rs = [[1,2,3],[2,3,4],[3,4,5]];
    	// $rs = json_encode($rs);		// This doesn't work either.
    ?>
    	

    Please can someone point out the cause of error here. 

    Thanks !

     

  13. Hi !

    I am creating everything through javascript, since the number of fields are dynamic in the sense that they can change. I can need all the way from 10 to 20 fields and depending on that I would need to set them with different font and ( box ) size settings to have a proper page layout. 

    Is it not a good idea to use JS to create the page ?

    What would you suggest?

    Quote

    map, each, same difference.

    I think you mean that I should use map to get all the values ( that i have already tried out ) and then use for each on that to target the values one by one. correct ?

    Thanks !

  14. Hi Requinix !

    Quote

    Before that, you know you're wrapping each input in its own form, right? Separately?

    Now that you point it out, I can see it ? ! Thanks ! And now that you told me, kindly help me resolve it as that as well !

    I couldn't get the map function to resolve the issue so i used this instead :

    $.each(test_arr, function(i, item) { ... });

    So please help me wrap all the fields in a single form so that they may be submitted with a single button click.

    Thanks loads !

  15. Hi all !

    I have created an array of input boxes and i wish to target each individually to check its contents after the user has input some values and pressed the click button.

    I have a fiddle at  http://jsfiddle.net/crnsbz5a/13/

    When the button is clicked, I want to compare the values of the input fields against the "a" array. If there is a mismatch I want to change the background color of the input box to a different color. 

    I cannot figure out how to target the individual input box. 

    Thanks all ! 

     

  16. Thanks Guru jacques !

     

     

     

    If somebody told you otherwise, they're wrong.

     

    I was actually referring to this article here under Method 2: but I may have misunderstood what the author is saying. Maybe what he is saying is correct and my understanding of it is wrong.

     

    You did not say anything about the 710 permission on the php scripts and such folder outside the root and so I take it that it is correct. 

     

    That almost clears it. If you could also say something about the file permissions in these folders, that would be really nice.

     

    Thanks again ! 

  17. Hi Guru Jacques  :) ,

     

    Thanks for the reply. 

     

    If I read you correct then for the 1st part of my question i.e. 

    1. php scripts, library or included or required files containing php code. ?
    

    you suggest that the folder permissions should be 710.  

     

    and for the 2nd part, i.e. 

    2. a folder that only contains uploaded images by the users remotely. ( Like a picture of a user on filling a form ) ?
    

    they should be either 770 or 750. ( 770 because the web-server also has to read them to display them ?)

     

    Kindly confirm that my deduction is correct. Also please shed some light on what should be the permissions for the files in these folders.

     

    Also, Guru Jacques, your answer implies that if I am logged in the machine as user master, and www-data is the web-server user and group, then the owner : group relationship for all the files should be  master : www-data.  Right ?

     

    If this is indeed what you meant, then I would like to ask that for a folder outside the root holding scripts and libs, which are to be accessed only by the php, and that too as read only, would the assignment www-data : www-data be more secure and should it be used?

     

    I read that for such a folder, the owner and group should be both assigned to the web-server (php) which is what I guess this (www-data : www-data) assignment is. If so, another question that arises is that, if these files need to be modified at a later time by the user master, then will the permissions have to be re defined to give the ownership back to the user master before they can be edited/modified?  

     

    Is my understanding of all this correct ?

     

    Thanks loads !

  18. Hi all !

     

    What are the best permissions, on a VPS, that should be set on files and folders that contains :

     

    1. php scripts, library or included or required files containing php code. ?

     

    2. a folder that only contains uploaded images by the users remotely. ( Like a picture of a user on filling a form ) ?

     

    I would be grateful with suggestion  and the reasoning for the same as well as who would need to own those permission. I have read quite a bit about the permissions but together with this ownership business it kind of confuses me utterly.  :confused:

     

    Thanks 

  19. Hi kicken, 

     

    Thanks for the reply.  :happy-04:

     

    It's not that I see any point in the extra /magical folder at the end, it's just that I am trying to figure out where to place my project folder so that when I type magical.com as the URL, it should access the index.php of my project folder. . :confused:

     

    All the examples that I came across just show a index.html inside the public folder. None showed how to handle a project folder that contained the index.html and the rest of the project folders and where to place that project folder.  

     

    Please show me how best to place my website / project folder in the directory hierarchy so that it may access my project's index.php when I type magical.com in the URL 

  20. Hi requinix,

     

    I am at a stage where I really want to check whether my website is good for a server and therefore try it out in a real development environment or as close to it. So i have to know how to get my website up and running on a server. So it was important for me to know the where and how on a server. 

     

     

     

     

    Personally I would make "magical" its own site at /var/www/magical.com but fact is it doesn't really matter.    

     

    I think you mean I don't really need to have these two - /myproject.com/public/ -folders in between. Correct ?! Please affirm. i'll head back to get the site up.

     

    Thanks ! 

  21. Hi requinix,  

     

    Thanks for the reply. 

     

    You wouldn't be angry if i told you that I did?  :happy-04:. I did, But i thought that it was also convention  to have the public folder as the last in the document root. i.e. either public or public_html or html, because every search on google showed the document root to end in the public folder. So I thought it was mandatory to have the public folder there and so there was some mechanism for what I wanted. 

     

    Just one thought then, what's the use of myproject.com in /vagrant/myproject.com/public. I would rather have /vagrant/magical.com/public/magical. Would that not be more logical and nicer? What do you say?

     

    Thanks again ! 

×
×
  • 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.