Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About ajoo

  • Rank
    Prolific Member

Recent Profile Visitors

6,753 profile views
  1. ajoo

    need some sound advice.

    Hi Guru Barand ! 🤔😲 $(doucment).ready(...) Sir you have the Midas touch ! Thanks loads !
  2. ajoo

    need some sound advice.

    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 !
  3. ajoo

    need some sound advice.

    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 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 !
  4. 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.
  5. ajoo

    pass a php array into js

    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 !
  6. 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.
  7. 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 !
  8. 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 !
  9. ok Guys, I got it ! While this var test_arr = $("input#reply"); works for dynamically created input boxes using JS, it does not work for boxes created using php. This works though test_arr = $("input[id='reply[]']"); I thought the first one looked more elegant ! Thanks !
  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. ajoo

    pass a php array into js

    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 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 requinix, Thanks for that insight ! That's what I will do then. Thanks !
  14. 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? 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 !
  15. Hi Requinix ! 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 !

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.