Using PHP script to replace a field in HTML form [closed] - php

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 to use PHP script to replace the 7th character of a HTML form input Field.
Eg.
A234591Q
To become
A23459IQ
Replacing number1 with I letter.
The problem is that I don’t have acess to php script file, so I need to do it in HTML page as customer types data, or at submit time.
Moises

If you have the JQuery library linked on your page, then you can try the following.
First you should give your input an ID e.g <input type="text" id="useranswer">
Then set the onsubmit property of your HTML form to:
<form action="" onSubmit="replaceAt(7,$('#useranswer').val())">
Then define the replaceAt Function.
function replaceAt(index,word){
newWord=word.substr(0,index) + 'l' + word.substr(index+1);
$('#useranser').val(newWord);
}
I have just given the answer for your question as it is not clear how you plan to implement it without access to the source

Related

Is it possible to have a form that has two submit buttons that go to separate form processing pages? [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 2 years ago.
Improve this question
I have a form that currently goes to a PHP page to process the data from the form and output it to plain text. However, I would also like an option to have the output use special HTML formatting. Is that even possible?
You can use the formaction-attribute on the button like this:
<form method="post" action="show-as-text.php">
<button>Show as text</button>
<button formaction="show-as-html.php">Show as html</button>
</form>
The formatction-attribute on the button will override the forms action.

html - text in a textarea without formatting? [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 8 years ago.
Improve this question
Right now I'm taking text from one form on a page to a separate page and form. I use $_GET to get the variable and just echo out the string between the textarea tags. The problem is formatting in the php seemed to be preserved. I got an if statement in there so it's pretty off.
I tried trimming the variable but that didn't do anything. Then I stripped out the PHP and typed free hand in between the tags. Is there a way to put text in a textarea without formatting?
Make sure your file ending is .php and that you properly open your PHP in the textarea, i.e.:
<textarea>
<?php if(isset($_GET['fieldName']) echo $_GET['fieldName']; ?>
</textarea>

Outside Website Custom Search in Joomla [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 8 years ago.
Improve this question
I need to create a custom search box that leads to an outside url and I'm trying to figure out the best way to do this in Joomla 3.0
For example: We need to create a text field with character input and have a button that when clicked takes the data in the text field and inserts it into the "variable" part of this URL and then takes you to this URL:
https://forexample.com/storefront/search.do;jsessionid=CD66CBFCC5658D6C9327AA269764EBB2?searchType=keyword&keyword="variable"&emailAddress=
You could use jQuery:
$("button").click(function() {
var variable = $("#textbox").val();
window.location.replace("yoururl&" + variable);
})

PHP dynamic page variable passing without submit button [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 MySQL query which will return a module code from the database. Let's say I have a template file (i.e. course.php) and what I would like to achieve is that I want to create a dynamic page with the name of the module code returned by the query (i.e. course.php?course=CS1231). However I don't have a submit button in course.php which allows me to pass that variable using GET method into URL. How can I achieve that?
AFAIK you don't need a submit button to use $_GET if your URL looks like this course.php?course=CS1231
You can just redirect to the page e.g.
<?php
$variable='course.php?course=CS1231'; #Whatever is returned by your database
header('Location: http://www.example.com/'.$variable);
exit;
?>
And in course.php you use $_GET['course'].

i want to pass a string from one input box to another in different page [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 8 years ago.
Improve this question
i want to pass a string from an input box that after submition automatically goes to different page and the string gets copied in the input box in that page .the Language I am using is php.
In your second page, you need to read the incoming value from the input box and include it in the output (which includes the second input box). Do not forget to pass the value of the variable through htmlspecialchars, since you are outputting it as part of your HTML.
So the code for the second page would look something like this:
$incoming = $_REQUEST['name_of_input_box_1'];
echo '<input type="text" name="name_of_input_box_2" value="'
.htmlspecialchars($incoming).'" />';

Categories