I wonder whether someone could help me please.
I'm put together the following form contained within a PHP file.
<form name="savemyfindstolocation" id="savemyfindstolocation" method="post">
<p><label></label>
</p>
<p align="left">
<input name="userid" type="text" id="userid"/>
<input name="locationid" type="text" id="locationid"/>
<br />
</p>
<div>
<label>
<div align="left">Click on the map to place the marker for the find that has been made and drag until the precise location has been found. </div>
</div>
<p align="left"><label>Find OSGB36 Latitude Co-ordinate<br />
</label>
</p>
<div>
<div align="left">
<input name="findosgb36lat" type="text" id="findosgb36lat" size="20" />
</div>
</div>
<p align="left"><label>Find OSGB36 Longitude Co-ordinate<br />
</label>
</p>
<div>
<div align="left">
<input name="findosgb36lon" type="text" id="findosgb36lon" size="20" />
</div>
</div>
<p align="left"><label>Date of Trip<br />
</label>
</p>
<div>
<div align="left">
<input name="dateoftrip" type="text" id="dateoftrip" size="10" />
</div>
</div>
<input name="submit" type="submit" onclick="MM_callJS('savedata()')" value="Submit" />
</form>
It all works fine, but I'd now like to add a button that opens the following php page, 'blobupload.php'. If I've understood this correctly from the research that I've done, I need to use javascript to open the page, using the 'submit' action from the main form.
What I don't understand is how to do this when the 'submit' action is already taken for the saving of the information on the main form.
Could someone perhaps please show me how to get around this, i.e. using the same 'submit action but for two different purposes.
Just modify your form tag (add the action attribute to file you want to load):
<form name="savemyfindstolocation" id="savemyfindstolocation" method="post" action="blobupload.php">
And you submit input tag:
<input name="submit" type="submit" value="Submit" />
You can use a second javascript function to open new window like this way
<input name="submit" type="submit" onclick="MM_callJS('savedata()');SECOND_JS_FUNCTION()" value="Submit" />
Use php to process the form is one of the way to do it.
<input name="submit" !!!!!!action="process.php" method="POST (or get)!!!!!!!!!! type="submit" onclick="MM_callJS('savedata()')" value="Submit" />
that way the the variable will be passed to the process.php while you can also redirect the page in the process.php
header("Location:URL");
Related
I have an HTML input and button:
<form action="validate.php" method="post">
<!-- THE CODE INSERT -->
<div id="code">
<form>
<label></label>
<input id="input" name="InputText" type="text"/>
</form>
</div>
<!-- THE BUTTON ITSELF -->
<input type="button" id="button" name="myButton"><b>Search Archive</b>
</form>
in my validate.php file I have this switch statement:
<?php
switch ($_POST["InputText"])
{
case "someval":
http_header("someaddress.com");
die();
break;
}
?>
the problem is that when I click the button it doesn't do anything. I did this with JS and it worked but it should be noted that I'm really new to web development so if anyone can explain to me what I did wrong and specifically why that would be great. Thanks!
You have a form inside of a form, that won't work. Also, you need to include an <input type="submit" value="submit" /> before you close your form. This is what submits the information from the form to your action="file.php".
A form would typically look like this:
file.html
<form action="validate.php" method="POST">
<input type="text" name="username" placeholder="Enter your username" />
<input type="submit" name="submit" value="Submit" />
</form>
Then you'd do something like this:
validate.php
<?php
echo "Your username is" . $_POST['username'];
The $_POST['username'] is the data gathered from the name="username" input from the HTML. If you write die($_POST); you'll get all the data that is sent through the form.
When you are using type='button' you have to perform the submit by yourself.
So, you can do that using javascript or change to type='submit'.
Example:
<input type="button" id="button" name="myButton"><b>Search Archive</b>
To
<input type="submit" id="button" name="myButton" value="Search Archive" />
you can try this
<form action="/validate.php" method="post">
<!-- THE CODE INSERT -->
<div id="code">
<label></label>
<input id="input" name="InputText" type="text"/>
</div>
<!-- THE BUTTON ITSELF -->
<button type="submit" id="button" name="myButton">Search Archive</button>
</form>
in the div id ="code" you used form tag that's why its not work...delete it will work and button type must be submit
I want to add text without reloading the page.
Here I have 2 TField (each with button POS and NEG) and 2 TArea (1 TArea POS and 1 TArea NEG).
when i input some text in first TField and then press POS button, the text added to TArea POS, and vice versa, if there is input in second TField then i hit POS, then my input append to TArea POST too.
In pure php with using FORM I could do it. but here I want page without reloading.
<div id="retrain" >
<input type="text" id="tweet" name="tweet" title="Teks retrain" />
<input type="submit" id="pos" name="pos" value="POS"/>
<input type="submit" id="neg" name="neg" value="NEG"/>
</div>
<div id="retrain" >
<input type="text" id="tweet" name="tweet" title="Teks retrain" />
<input type="submit" id="pos" name="pos" value="POS"/>
<input type="submit" id="neg" name="neg" value="NEG"/>
</div>
<div id="box" >
<textarea style="width:420px" name="posbox" rows="4" cols="70"></textarea>
<textarea style="width:420px" name="negbox" rows="4" cols="70"></textarea>
</div>
<?php
if (isset($_POST['pos'])) {
}
if (isset($_POST['neg'])) {
}
?>
Can you help my case?
Thanks for the help.
note : here i using same ID for all my input.
You cant do asynchronous requests with php. It is server compiled, not like javascript that is compiled by the browser..
learn how the internet works!
You can change fields in html with Javascript. The problem of your code is that your buttons are "submit" and thus a form has to be submitted (the page reloaded, etc). With these small changes you can get what you want:
<html>
<head>
<script>
function changeField()
{
document.form1.tweet.value=document.form0.tweet.value;
}
</script>
</head>
<form name='form0' id='form0'>
<div id="retrain" >
<input type="text" id="tweet" name="tweet" title="Teks retrain" />
<input type="submit" id="pos" name="pos" value="POS"/>
<input type="submit" id="neg" name="neg" value="NEG"/>
</div>
</form>
<form name='form1' id='form1'>
<div id="retrain" >
<input type="text" id="tweet" name="tweet" title="Teks retrain" />
<input type="submit" id="pos" name="pos" value="POS"/>
<button type="button" id="neg" name="neg" value="NEG" onclick="changeField();">NEG</button>
</div>
</form>
</html>
Logically, the only button including the new functionality is "neg" in form1: when it is clicked, the text in the "tweet" textbox above is written into the one below.
I have two forms on a page-'indexpage plus a included page'. Their actions point as so action=''. The problem is when I hit submit on the search bar, it shows a header error. The submit for the login works fine. I narrowed the problem all the way down to
tabindex="6" type="submit"
in the submit button of the login form.
They both have different names.
Login Form:
echo'<div id="container">
<div id="topnav" class="topnav"> <font color="white">Have an account?  </font> <span>Sign in</span><span>Sign Up</span> </div>
<fieldset id="signin_menu">';
output_errors($errors);
echo'
<form id="signin" action="" method="POST" >
<br>
<label for="username"><font color="black">Username or email</font></label>
<input id="username" name="username" value="" title="username" tabindex="4" type="text">
</p>
<p>
<label for="password"><font color="black">Password</font></label>
<input id="password" name="password" value="" title="password" tabindex="5" type="password">
</p>
<p class="remember">
<input id="signin_submit" name="submit" value="Sign in" tabindex="6" type="submit">
<input id="remember" name="remember_me" value="1" tabindex="7" type="checkbox">
<label for="remember"><font color="black">Remember me</font></label>
</p>
<p class="forgot"> Forgot your password? </p>
<p class="forgot-username"> <A id=forgot_username_link
title="If you remember your password, try logging in with your email"
href="/recovery/username">Forgot your username?</A> </p>
</form>
</fieldset>
</div>';
Search Form:
<form action='' method='POST'>
<input type='text' value='". $clean ."' name='keywords'/>
<input type='submit' name='submit2' Value='Search'/>
</form>
Header Error:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files
(x86)\xampp\htdocs***\index.php:298) in C:\Program Files
(x86)\xampp\htdocs***\pages\search.inc.php on line 35
I'm petty sure that error is due to you trying to output (echo/print) something before trying to redirect in the headers. Redirects header('Location: /anotherpage.php'); after an echo or some printed HTML are probably the cause.
I found the problem in my input for the login submit. Here is what I did.
I change this
<input id="signin_submit" name="submit" value="Sign in" tabindex="6" type="submit">
Too this
<input name="submit" value="Sign in" type="submit">
Apparently the tabindex and id had some kind of issue, not sure why.
Hi having a problem with this code even if i clicked on cancel it will still proceed to use the action of my form even though the CANCEL button is not part of the form, Would appreciate any help.
Here is the code.
<form method="post" action="input_enroll.php" >
<div id="overlay1">
<div>
<h1> Enter Educational Level Entry</h1>
<input type="text" name="level" >
<input type="submit" value="Proceed To Enroll" '>
</form>
<input type="submit" value="Cancel" onclick='overlay()'>
</div>
</div>
EDIT: Any suggestions what would be a better idea? I'm thinking putting the cancel outside the div.
You are having form started, then divs started, then form closed..start form after divs..
as your markup is not correct, browsers will change it as thier parser suggest,
In chrome </form> tag is postponed after </div>s..
<div id="overlay1">
<div>
<form method="post" action="input_enroll.php" >
<h1> Enter Educational Level Entry</h1>
<input type="text" name="level" />
<input type="submit" value="Proceed To Enroll" />
</form>
<input type="submit" value="Cancel" onclick='overlay()' />
</div>
</div>
I have a html form which posts to a php script. It works fine in chrome and firefox but not in IE. I have ran a test on W3C but can not find any errors that relate to the form. My code is:
<form class="formular" id="formular" method="post" action="script/contact.php">
<fieldset>
<label>
<span>Name : </span>
<input type="text" class="validate['required','length[3,-1]','nodigit'] text-input" name="Name" />
</label>
<label>
<span>Email address : </span>
<input type="text" class="validate['required','email'] text-input" name="email" />
</label>
</fieldset>
<div class="button">
<input type="submit" value="Contact" class="submit" />
</div>
</form>
Thanks in advance
Form is correct. Looks like wrong handling form on server side. how you catch result?