How to pass textbox value directly through Query String in php [closed] - javascript

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 8 years ago.
Improve this question
I want to pass textbox value directly through query string the first variable is passed but the second value will be textbox value on the same page. Please help. Thanks
<input type="text" name="txtswap" id="txtswap" size="5" />
Swap

This can't be done with PHP alone, you need some JavaScript for it:
<input type="text" name="txtswap" id="txtswap" size="5" />
Swap
JavaScript:
function doSwap(self, event)
{
var swapValue = document.getElementById('txtswap').value;
event.preventDefault();
location.href = self.href + '&value=' + encodeURIComponent(swapValue);
}

<input type="text" name="txtswap" id="txtswap" size="5" />
<a onclick="swap()" >Swap</a>
<script>
function swap() {
var swapvalue = $('#txtswap').val();
window.location.href = 'UserForm.php?operation=swap&id='+swapvalue ;
}
</script>
Try this
Not tested...

Try this .
Swap
Write JavaScript function
function redirect(){
txtswap = document.getElementById("txtswap").value;
window.location.href = "UserForm.php?operation=swap&id="+txtswap;
}

Since the text box in the same page, you can't use PHP for this. PHP won't see the data (because it won't exist at the time the PHP runs).
Stop using a link and use a form instead, converting user input into a URLs is what they are for.
<form action="UserForm.php">
<input type="hidden" name="operation" value="swap">
<input type="hidden" name="id" value="<?php echo htmlspecialchars($row['id']; ?>">
<input name="txtswap" id="txtswap" size="5">
<input type="submit" value="Swap">
</form>

Related

How to create 'add quantity' input box and embed it inside PHP scripts? [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
Thanks for those who helped! I have figured it out!
How can I create a input field like the one in the image? And I want to embed it inside $_POST. Thanks for your time :)
This is an HTML5 input of type number. You use it this way:
<form method="POST" action="yourPHPfile.php">
<input type="number" name="number_input">
<input type="submit">
</form>
When this form is submitted, it will send the selected number to yourPHPfile.php and you can retrieve the number from $_POST['number_input']
You can use input for the number selecotr and post using a form like so:
<form method="post">
<input type="number" name="intNumber"/>
<input type="submit" />
</form>
Then in PHP you can do this
<?PHP
if(isset($_POST['intNumber'])){
$myNumber = $_POST['intNumber']; // intNumber is the name of of your input
}
?>
When the submit button the PHP will be fired.
Hope this helps!

Php form submit alert if less than 1min passed [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 7 years ago.
Improve this question
I need some help with my php code
<?php
date_default_timezone_set('America/Los_Angeles');
$now = date("H:i:s");
?>
<form method="post" name="update" action="update.php" />
<input type='text' name='fname' value=''>
<input type='text' name='lname' value=''>
<input type='text' name='email' value=''>
...
<button type="submit" value="Submit"/> Submit </button>
</form>
What i need:
If someone clicks on button submit but it passed less than 1 min since start($now)
then it must appear an Alert "Check Info"(not another page or popup),
an alert like "Do you really want to leave the page?"
I should not work for free... but I won't give you the full answer!!! Make an effort and fill in the right code <<< FILL >>> to get it to work!!!
<script src="<<<FILL>>>"></script>
<script>
submitAllowed = false
$("form").submit(function(e){
e.preventDefault();
if (<<<FILL>>>||confirm("Do you really want to leave")) {
this.submit()
}
});
function submitAttempt(){
submitAllowed = true;
}
setTimeout(<<<FILL>>>, 60000);
</script>

Populate hidden text input using jQuery [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
<input name="input1" id="input1" type="text" value="" class="problem">
<input name="input2" id="input2" type="text" value="" class="hidden">
I'm trying to populate a hidden text input (e.g. input#input2) field with the current value from another text input field (e.g. input#input1) (un-submitted) using jQuery. I've sourced this jsfiddle doing exactly what i require but with a drop down field. And i was wondering if anyone is able to point me in the right direction?
EDIT: Sorry if i wasn't clear, the jsfiddle works perfectly but i'm trying to use a text field instead of a drop down to populate the other field.
i always handle this by storing that value in a variable:
var yourText = document.getElementById("input1").value;
and then just plug it into the hidden field:
$('#input2').val(yourtext);
here's your hidden field:
<input id="input2" type="hidden" />
$("#my_form").submit(function(event){
var visibleInputVal = $("#input1").val();
if(visibleInputVal != ""){
$("#input2").val(visibleInputVal);
}else{
alert("you need to provide a value for input 1");
event.preventDefault();
}
});
<form id="my_form">
<input type="text" value="" id="input1" />
<input type="hidden" value="" id="input2" />
<input type="submit" value="Submit" />
</form>

Call function on pass input in textbox [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 want to call the function in every input pass on textbox, but it does not work., either when i enter any input or remove input..it is work like intellisense textbox
<input id="btnSearch" type="text" value="Search" class="search_btn" onchange="Call()" />
<script>
function Call()
{
alert("Me");
}
</script>
Probably what you want to do is -
<input id="txt_Search" type="text" onchange="Call()" />
<script>
function Call()
{
alert("Search suggestions can come here!!");
}
</script>
Or, using simple jQuery
$("#txt_Search").keyup( function() {
var searchQuery = $("#txt_Search").val();
alert("Seacrh suggestion satrting with - " + searchQuery);
});
you can also use textbox events -
<input id="txt1" type="text" onchange="SetDefault($(this).val());" onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();">
jquery -
function SetDefault(Text){
alert(Text);
}
Try This

Move the index of a selection into a text field when press submit [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 want to copy the index of a selection into a text field when the submit button is pressed. For example, I want to copy the name 'Accountant' of an option in the selection list into a textbox when I choose the option.
This is the HTML:
<form action = "">
<select name = "job_term_cat">
<option value="----">--Select--</option>
<option value="roma">Accountant</option>
<option value="torino">Cashier</option>
<option value="milan">Lawyer</option>
</select>
<br/>
<br/>
<input type="text" name="job_title" value="" />
<input type="submit" value="Test">
</form>
Here is the JavaScript I thought going to work for submit button, it returns no index of the option that is clicked.
<p><input type="submit"
onclick="var s= this.form.element[job_term_cat];
this form.elements[job_title].value= s.options[s.selectedIndex].textContent"
class="submit" name="job_submit"
value="<?php _e('Next →', 'myapp'); ?>" /></p>
var s= this.form.elements['job_term_cat'];
(mind the s in elements and the quotes)
this form.elements['job_title'].value= s.options[s.selectedIndex].textContent;
(mind the quotes)
well, you have some errors in your syntax, for example not var s= this.form.element[job_term_cat]; but var s= this.form.elements[job_term_cat];
here is the working code:
EDIT: I misplaced some names, check this:
<p><input type="submit" onclick="this.form.elements['job_title'].value = this.form.elements['job_term_cat'].selectedIndex" class="submit" name="job_submit" value="<?php _e('Next →', 'myapp'); ?>" /></p>

Categories