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 last month.
Improve this question
I need to make a text that can be edited by user but in some parts I need to make static text for example the date and ....,how to make it ,plz can anyone help me
I have tried the normal input but it did not work as I expected
you can define editable part in page for each section, after type in input with js concatenation all text in main input, and in submit just pass main text to back-end.
like bellow:
<input type="hidden" name="text" id="main-text-id">
<input class="text-part" type="text">
<input class="text-part" type="text">
<input class="text-part" type="hidden"> <!--static part-->
<input class="text-part" type="text">
<input class="text-part" type="hidden"> <!--static part-->
...
and your script :
<script>
const mainText = document.getElementById('main-text-id');
const inputs = document.querySelectorAll('.text-part');
inputs.forEach(input => {
input.addEventListener('input', () => {
mainText.value = Array.from(inputs).map(input => input.value).join(' ');
});
});
</script>
Related
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 2 years ago.
Improve this question
I have a bit of a problem. I have element with form::input in it. And i want to get lebel text and input value at the same time and pass it to another element as value.
For ex.
<label for="contact">Only contact if the fee is over <input id="jpy" min="0" name="JPY" type="number" value=""> JPY(Include tax)
</label>
What i want to achieve is to pass "Only contact if the fee is over 1000 JPY(Include tax)" as a value to another element.
I know how to get .text() of label element and i know how to get value from input. But i don't know how to get them at the same time in consistent form.
You can use .contents(), but a better approach would be to use label tag correctly:
$('button').on('click', () => {
let contents = $('label').contents()
console.log(contents[0].wholeText + $(contents[1]).val() + contents[2].wholeText)
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label for="contact">Only contact if the fee is over <input id="jpy" min="0" name="JPY" type="number" value=""> JPY(Include tax)
</label>
<button id="button">Get text</button>
$('button').on('click', () => {
var label = $('label[for="contact"]').text();
var input = $('#jpy').val();
console.log(label+' '+input);
});
Hope this works
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 3 years ago.
Improve this question
I am creating a small real estate website, but need some help in search results. my website is in WordPress.
I want this kind of results:- https://www.affordablehousinggurugram.in
my code is
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div>
<input value="<?php echo get_search_query(); ?>" name="s" id="<?php echo $unique_id; ?>" type="text" placeholder="<?php echo $houzez_local['blog_search']; ?>">
<button type="submit"></button>
</div>
</form>
This is not a trivial problem, but conceptually you would approach it as follows.
In a text input, call a function every time a user enters a value:
<input class="someClass" id='someId' name='someName' type='text' onkeyup='getProperties(this.value)' >
Where getProperties uses ajax and might look something like this:
function getProperties(value) {
$.post(
"somePHPFile.php",
{query: value},
function (data) {
$(".results").html(data);
}
);
}
This function sends value (the user input) to somePHPFile.php, which returns data and this data is inserted into the HTML element with class results (which is the 'live' results as the user types. As a result, somePHPFile.php needs to contain your call to your database.
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 6 years ago.
Improve this question
Helou,
I have a form like this
<form id="some" data-request="checkout" class="checkoutForm">
<div class="form-group mb10">
<label for="firstName" class="col-sm-12">Name <span class="color-main">*</span></label>
<input class="form-control checkout-form-border" id="firstName" value="" type="text">
</div>
<div class="form-group mb10">
<label for="Address" class="col-sm-12">Address <span class="color-main">*</span></label>
<input class="form-control checkout-form-border" id="address" value="" type="text">
</div>
etc etc ....
</form>
Now, I want on submit button show new page with collected data from this form in a table body.
Can I do this via php and jquery or new custom component?
Thanx
PHP:
need a submit button in the form
need action=" " and method="post" attributes added to your form tag
need to add name attributes to your input boxes
Top of page,
if(isset($_POST['submit'])){
$variable = $_POST['namedOfInputBox'];
echo "<table><tr><td>$variable</td></tr></table>";
{
What that says is if the form is submitted (submit being name of your submit button, generally name it submit), the values coming through are these and in PHP we "echo", or print, out html code and place our variable here. You can either use :
echo "<table><tr><td>$variable</td></tr></table>";
or
echo "<table><tr><td>" . $variable . "</td></tr></table>";
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
I have a page that is receiving an array from $_GET. Lets say it has 3 values in $_GET['types'] containing: 'good', 'bad', and 'ugly'. Now on this page I am setting up a form and I need to pass this array into the form through an input. Maybe this short piece of code can help demonstrate what I'm trying to do
<form action="dosomething.php" method="get">
<input name="types[]" value="<?php echo $_GET['types']; ?>" />
</form>
How can I accomplish this?
Arrays in string context are simply the literal word Array. You say $_GET['types'] is an array, therefore you're generating this html:
<input ... value="Array">
You should have
<input name="types[]" value="<?php echo implode(',', $_GET['types']); ?>" />
instead.
But note that you'll end up with this html:
<input ... value="foo,bar,baz">
and this in $_GET on the server when the form's submitted:
$_GET['types'] = array(
0 => 'foo,bar,baz'
);
If you want those values as SEPARATE array entries, you'll have to submit multiple input fields:
<input name="types[]" value="foo">
<input name="types[]" value="bar">
etc...
which will give you
$_GET['types'] = array(
0 => 'foo',
1 => 'bar'
etc...
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 7 years ago.
Improve this question
first textfield should be disabled and when i clicked on check box, textfield should be active.
echo'<input type="checkbox" name="checkbox"/>';
echo'<textarea name="explain" id="explain"
cols="" rows="" style="width:300 ;height:300"></textarea>
if(isset($_POST['checkbox']))
{
???
}
I think you should use this:
<form>
<input type="checkbox" name="checkbox" onchange="toggleDisabled(this.checked)"/>
<textarea name="explain" id="explain"></textarea>
</form>
<script>
function toggleDisabled(checked) {
document.getElementById('explain').disabled = checked ? false : true;
}
</script>
Full code is here
Your question a little unclear. I've interpreted this as you needing JavaScript to set the textarea to disabled and active on a checkbox value without going to the server.
Using Javascript you can add an event listener on the checkbox and check the checked property, then set the textarea to disabled or not.
document.getElementById("checkbox").addEventListener("click", checkbox_textarea);
function checkbox_textarea() {
if( this.checked == true ) {
document.getElementById("textarea").disabled = false;
return false;
}
document.getElementById("textarea").disabled = true;
}
<input id=checkbox type=checkbox name=chk /> Enable text area <br />
<textarea id=textarea name=txt cols=50 rows=20 disabled></textarea>