Set Button id from javascript

I have a dropdown list which filled with the data fetched from db. I need to assign the selected index value of this dropdown list as the ID of a button. Is it really possible? my code Answer Might be this will solve your problem. I have added a class on btn call CustomerModalBttn . Try this

Why the PHP can’t see a value which is coming from ajax js?

When I get my result from the JS side the value comes true. But I want to fill the value to my PHP file, so I’ve used ajax. When I delete if isset function in PHP , I got an “undefined index” error. HTML Side jS side And PHP side Answer You’re sending a value, but you’re not sending a key with that value. So for example if the value is 123 then you’re only sending 123, nothing else. So this won’t find it because there’s no key called ad in the data being sent: Add a key for the

How can I use javascript code in an external file with twig elements?

I have a lot of javascript code one my twig template home.html.twig, for example: Because the source code of my main page is now full of javascript I try to move it into an external file, to have a more clean appearance: But it does not work because I have so much twig variables, and they are not recognized anymore. For every twig variable I get an error message, like this for example: Answer First of all (as the comments already said) it is not a good idea to mix JavaScript with Twig. Makes your code hard to maintain, hard

PHP Post radio value to next page on radio click

I need some help with my code as I have got a problem with posting the value. When I click on the radio, it will not post the data when it redirect me to secondpage.php. I want to post the value when I click on the radio button to take me to the next page. firstpage.php secondpage.php It will show the empty data in the $_POST as I will get the results which it show Array ( ) when I am using print_r($_POST) in secondpage.php. What I am trying to achieve is when I click on a radio button, I

JavaScript and HTML element manipulation

Project Concept: Creating an “exam maker”, which can be accessed by a teacher to create and let a student be able to access it to take. Many features would be included but to keep it simple on the question at hand i wont be including all info. Front End: List all questions in the database, using a php file, to a select field in HTML. When the item is selected add it to the test. Display the test, and assign scoring to each question. My Actual Question/Help: My addq() function is supposed to, get the value of selected item, append

Get a HTML input value out of a file which is located in a subfolder?

I’m trying out to develop a small shortcode WordPress Plugin. Therefore, I created a main php-File and in a subfolder the HTML-File. The subfolder (classes) is located on the same level as the php-File. In the HTML-File I’m opening a Modal to enter data. By pressing the save button, a method in the php-File is called which should write date into the WordPress-Database. php-File (shortcode-concerts.php) classes-Folder HTML-File (mainLook.html) The code snippet shows how I tried to get the values via JavaScript and document.getElementById() out of the HTML-File – which doesn’t work cause it’s returning null. By alerting concert.value the alert

PHP Disabling registration from any mobile device, only allow user registration from a Desktop

I usually post code but this is a slightly different case. I would like to disable my registration page from being used on a mobile device. EG:’s login is not accessible from any mobile device. So what I came to conclude is that I might need to catch the users user-agent and if its a mobile platform redirect it to a disabled page? I’m not really sure as to how to go about this, meaning could this be disabled via apache2 or a simple user-agent grabber using PHP or JS? Answer You can use a php class called

Call php function with onclick event?

I want to delete project from database.Before deleting I want to confirm it whether user want to delete or not.If user click on okay it has to call delete function.But in the code when user click the function is get called not only user click on okay but also click on concel.For other alter statement it is working fine.For calling php function only it gives problem. How can I solve this? code is, Answer Just follow this code to achieve using jQuery ajax call. This is the HTML code with jQuery included and I’ve used test.php file in the same

PHP: How to allow users to change background color of their profile?

I have made a social networking site. One of the feature I would like to add is to allow users to change the background image of their profile.I have written javascript for it, but once I change background image of one user, all users background change to that image. What should I do to avoid this. Javascript Code for switching background Change background option in Settings page Answer You should load the background image dynamically for each user. This is just a streamline of what I think you should do: Create a field in the DB for every user to

How to create a timer

I have a $dbSessionDuration variable where by using mysqli, it is able to bind the result of data from the query into this variable. The $dbSessionDuration variable holds time so the variable has a time format as below: 01:30:10 Now that means 1 hour 30 mins and 10 seconds. What I want to do is display $dbSessionDuration value in a timer so that in above’s example it will start ticking down from 01:30:10 and go all the way to 0 when it stops. My question is how do you create timer and place whatever value $dbSessionDuration value in the timer