I have a php signup form. I have a text field named username ie, <input type="text" name="username"> to enter username. I have a button next to it with value and name as check. I want to popup a small window when user click the check button. I just want the entered text (username) to get displayed in the popup window.
The key need is to transfer the data from this window to popup window.
How can I make this possible??
I'm not pretty sure what are your really wanted. I guess experimentX has a point. Anyway try this code. But first your calling page must be a php.
PHP:
<p>User Name is: <?php echo $_GET['userName']; ?> </p>
HTML
Forwarding value via URL
<form>
<p>
<input type="text" name="userName" />
<input type="button" value="check" onClick="window.open('popWindow.php?' + 'userName=' + this.form.userName.value, '_new')" />
</p>
</form>
Forwarding value via submit:
<form action="popWindow.php" target="_new" method="GET">
<p>
<input type="text" name="userName" />
<input type="submit" value="check" />
</p>
</form>
I hope this can help. If not please be more specific and provide more of your code.
Related
The problem im having is i want the user to input the answer to the input box and when submit button is clicked the box should highlight green if correct and red if incorrect.
<form method="POST" action="">
<h2>Challenge 2</h2>
<p>Key: puck</p>
<p>Message: lbcd uiqvh njohy oygncvh vg
</p>
Answer:<br>
<input type="text" name="answer2" value="">
<br>
<input type="submit" value="Submit">
</form>
Expected results should give the user an indication if they are wrong or right in answering the question.
You will want to use JavaScript
Answer:<br>
<input type="text" id="answer2" name="answer2" value="">
<br>
<input type="button" onclick="checkIfCorrect()" value="Submit">
</form>
<script>
function checkIfCorrect(){
var answerValue = document.getElementById("answer2").value;
if(answerValue == "expectedAnswer")
doSomething();
}
</script>
However this means the "expectedResult" will be inside the code that is sent to the user and can be easily viewed inside the developer console. If you want to hide the value you're looking for from the user you will need to use ajax.
https://www.w3schools.com/js/js_ajax_intro.asp
I am trying to make a button in which it grabs the value from the SQL 2008 server and then becomes the POST data. Here's what I've been trying:
<form method="post" action="scripts/php_orderview.php">
<input type="text" name="order_ID">
<?php echo $row['order_ID']?>
<input class="submit" type="submit" value="View">
</form>
This just comes up with an empty box. Any help would be appreciated.
I think you want:
<input type="text" name="order_ID" value="<?php echo $row['order_ID']?>">
basic html form, value attribute is the text in the box
This is hard to explain so bear with me.
I'm building a page that consists of multiple forms that are all submitted with one submit button at the bottom like so:
<form action="" method="post">
<input type="text" name="name1" value="<?$variable1;?>" placeholder="Type here...">
<form action="" method="post">
<input type="text" name="name2" value="<?$variable2;?>" placeholder="Type here...">
<form action="" method="post">
<input type="text" name="name3" value="<?$variable3;?>" placeholder="Type here...">
<form action="" method="post">
<input type="text" name="name4" value="<?$variable4;?>" placeholder="Type here...">
<input type="submit" name="submit" value="Submit">
</form>
Each of these forms asks the user for data, which then echos to a text box so that they can copy/paste the output.
Now, suppose the user fills out the data for one of these forms only and clicks on the submit button. Naturally, the data they entered would go to the text box. What I need however is that when the user then decides to fill out the rest of the forms, the data that was originally echoed is still in the text box, preferrably as well as the answer they put in the form (however not essential).
What I'm finding at the moment is that the form resets after clicking submit, so even though the user has submitted one part of the form, when they go to fill out the rest and click submit again, only the other 3 are echoed and the first one is omitted.
I hope this makes sense. Any idea on how one would go about this?
EDIT: Nearly got it with the following:
if (isset($_POST['submit'])) {
if (isset($_SESSION['test1'])) {
$_SESSION['test1']=$_SESSION['test1'];
}
else {
$_SESSION['test1'] = $_POST['test1'];
}
}
However the variable now doesn't change when we enter something new into the form field...
<form action="" method="post">
<input type="text" name="name1" value="<?$variable1;?>" placeholder="Type here...">
<input type="text" name="name2" value="<?$variable2;?>" placeholder="Type here...">
<input type="text" name="name3" value="<?$variable3;?>" placeholder="Type here...">
<input type="text" name="name4" value="<?$variable4;?>" placeholder="Type here...">
<input type="submit" name="submit" value="Submit">
</form>
Call only once. One submit button is for 1 form. Please try this. It should work
You need <?= $variable1; ?> etc. Otherwise it doesn't output anything.
I have a form in a PHP script and one text field. However when I press the enter key in a text field, the submit button does not set in the $_POST array.
But when I have two text fields in the form the submit button is set in the $_POST array.
This is happening in IE. Can anyone explain the reason behind this?
Below is the code I am testing with
<?php
print_r($_POST);
?>
<form action="" method="post" name="frmdata">
<input type="text" name="abc1" id="abc1" value="" size="20" maxlength="20"/>
<input type="text" name="abc" id="abc" value="" size="20" maxlength="20"/>
<input type="submit" name="submit1" value="submit1" id="submit1" />
</form>
If I remove one of the text box and submit the form by pressing enter key while entering text in the text box, IE does not set Submit button in $_POST array.
This does not set the Submit Button:-
<?php
print_r($_POST);
?>
<form action="" method="post" name="frmdata">
<input type="text" name="abc1" id="abc1" value="" size="20" maxlength="20"/>
<input type="submit" name="submit1" value="submit1" id="submit1" />
</form>
I actually got this while answering this question.
Thanks #Yaniro. It is a IE bug.
IE having bug with the single text element- That it is if you submit the form using the enter key the Submit button will not set in $_POST.
You must have at least 2 form element if you want submit button to set in $_POST when form submitted by pressing Enter key in IE.
Using the code below, I'd like to post or get the value returned (date) into a javascript window so that I can run a query off of the value. Can someone please tell me how to do this?
<form method="post" action="search.html">
<p style="padding:10px;">
<input type="text" id="date" name="date" value="" maxlength="10"> <img src="calendar.gif" class="cp_img" alt="Open Calendar" style="padding-bottom:3px;"><br /><br />
<input type="submit" name="search" value="Submit">
</p>
</form>
Is this just not possible??
If you can take your value to search.php, then you could store it in a session variable and recatch it from that session variable in your popup window.
Using the target attribute of <form> will allow you to post data to a new window directly.
<form method="post" action="search.php" target="newpopup">
<p style="padding:10px;">
<input type="text" id="date" name="date" value="" maxlength="10"> <img src="calendar.gif" class="cp_img" alt="Open Calendar" style="padding-bottom:3px;"><br /><br />
<input type="submit" name="search" value="Submit">
</p>
</form>
I am assuming that you are catching the data posted at search.php.
target also accepts _top, _blank, .. so on.
using the jQuery Form Plugin you could submit your form ajax-ily, and receive a return success event and values that you could easily pass in querystring of a window.open call and get the result you seek...
Thats just one way...
Another way is not use forms and submits, but just do a ajax post to php service and receive json results and pop up window or thickbox or whatever ..