pass value from button value to input text [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
May I Ask About Angular
I am a beginner and
I need to pass a value from Button to Input text
I have many Buttons like
When I Press abutton the Text Value will change

If you are using angular js then following thing can help you.
var app = angular.module('app', [ ]);
app.controller('MyController', function($scope) {
$scope.setValue = function(number){
$scope.myValue = number;
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<body ng-app="app">
<div ng-controller="MyController">
<button ng-click=setValue('One')>One</button>
<button ng-click=setValue('Two')>Two</button>
<button ng-click=setValue('Three')>Three</button>
<input value="{{myValue}}" />
</div>
</body>

Related

Display the value of form input [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have a form with a input field like this:
<input type="hidden" id="name" name="name" value="">
Value of this input is changing trough some javascript function.
Now i would like to displays this value dynamicaly. For example:
<h1>This is the name: *input name value here*</h1>\
I know that you can use the value from different elements on a form when submiting, using the $_POST["name"]. But what about getting the value on same page dynamicaly.
<input type="text" id="name" name="name" value="" onblur="myFunction()">
<h1 id="fname"> </h1>
<script>
function myFunction() {
document.getElementById("fname").innerHTML = document.getElementById("name").value;
}
</script>

How can I edit and save php files with php from admin panel? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need to edit php files from the admin panel. How can I do this? I've seen this in CMS like wordpress and joomla. Is there a php library or something?
I recommend Ace for that purpose. It is a code editor built in Javascript: https://ace.c9.io/
To read the files in and save them after editing, you can use built in PHP functions like file_get_contents() and file_put_contents().
Here is a minimal working example:
<?php
if (isset($_POST['code'])) {
file_put_contents('myfile.php', $_POST['code']);
}
$code = htmlentities(file_get_contents('myfile.php'));
?>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.0/ace.js"></script>
</head>
<body>
<form action="" method="post">
<textarea id="source" name="code" autocomplete="off" style="display: none"><?=$code?></textarea>
<div id="editor" style="min-height: 250px"><?=$code?></div>
<input type="submit" />
</form>
<script>
var tarea = document.getElementById('source');
var code = tarea.value;
var editor = ace.edit("editor");
editor.session.setValue(code);
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/php");
editor.getSession().on('change', function(){
tarea.value = editor.getSession().getValue();
});
</script>
</body>
</html>
Important: Set the correct permissions for the files you want to edit.

form input box to download files [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Developing a school website in WordPress and need to upload Progress Report of students in the server in pdf format. File name of Progress report will be the Admission number of the students (Eg. 123.pdf). When students enter their Admission number in the input box, they should get their progress report file downloaded. As of now using below form box to redirect to file url.
<script>
function process()
{
var url="http://demo.websign.in/" +
document.getElementById("url").value;
location.href=url;
return false;
}
</script>
<form onSubmit="return process();">
ENTER YOUR ADMISSION NUMBER: <input type="text" name="url" id="url">
<input type="submit" value="DOWNLOAD">
</form>
Any help as I am a theme developer and no much knowledge in coding?
You do not need form tag to download file. Also instead of type "submit" use "button". The js you need is something like this:
function myFunction()
{
var downloadUrl = document.getElementById("url").value;
document.getElementById("downlod").href = downloadUrl + '.pdf';
}
<div>
<label>ENTER YOUR ADMISSION NUMBER:</label> <input type="text" name="url" id="url" onkeypress="myFunction()">
<a href="foo" id="downlod" download><span>Download</span></a>
</div>

On/Off Button - Return True/False value with PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Using this guide to create a "button switch" like this: http://www.w3schools.com/howto/howto_css_switch.asp
What I would like to know, is how can I return a true or false value from this switch in PHP? So for example, I could use this switch like:
if( $button_value == true ) {
// do this
}
You need to give a name to the <input> element. If the button is checked, $_POST['name'] will be set in the PHP script when you submit the form.
So the HTML should be:
<!-- Rectangular switch -->
<label class="switch">
<input type="checkbox" name="switch">
<div class="slider"></div>
</label>
Then the PHP will be:
if (isset($_POST['switch'])) {
// do this
}

PHP - Send a GET Parameter by POST with formvalue [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i have a problem, i will send a POST with PHP but i will
send a GET Parameter with the form value:
<form action="/Eventsuche/" method="post">
<table>
<tr>
<td>
<input id="Headsucheort" name="Headsucheort" type="text" value="" />
</td>
<td>
<button type="submit" name="Submit" id="Headsuchestart" value="Headsuchestart">»</button>
</td>
</tr>
So, on submit he bring me to /Eventsuche/ but i would like to
go here: /Eventsuche/Value of Headsucheort
Thanks! :)
<button onclick="window.location.href='/Eventsuche/' + document.getElementById('Headsucheort').value">»</button>
Didn't test but
If you really must do it in PHP, add this to Eventsuch:
if ( isset($_POST['Headsucheort']) ) {
header('location:http://www.your-url.com/Eventsuche/'.$_POST['Headsucheort']);
exit;
}
I see two ways to the that.
first:
you can add your variable to the end of your action value such as: action="Eventsuche?var=somevalue"
and second one would be:
as a hidden input and even tho it is hidden, php will capture it on submit as in:
<input type="hidden" name="myvar_name" value="my_var_value" />
i think this should do it.

Categories