I have a simple HTML form.
<!DOCTYPE>
<html>
<body>
<center>
<form action="MYLINK" method="POST">
Tell your device what to do!<br>
<br>
<input type="radio" name="args" value="on">Turn the Light on.
<br>
<input type="radio" name="args" value="off">Turn the Light off.
<br>
<input type="submit" value="Do it!">
</form>
</center>
</body>
</html>
When the submit is clicked, the page redirects and Server's JSON reply is shown. I dont want that.
I added an IFRAME in the page and then added it as the form's target
<form action="MYLINK" method="POST" target="hidden-form">
...
</form>
<IFRAME style="display:none" name="hidden-form"></IFRAME>
Now the reply from server is not visible.
Related
I have a URL looks like this
site.com/dir/?id=xxx
is it possible to create an HTML form that allows the user to enter the value of id and opens the page in other tab?
thank you.
This is the very basic HTML code to do it :
<!DOCTYPE HTML>
<HTML>
<body>
<h1>The input element</h1>
<form action="https://www.google.com/dir/" target="_blank">
<label for="id">Enter value of ID:</label>
<input type="text" id="fname" name="id"><br><be>
<input type="submit" value="Submit">
</form>
<p>Click the "Submit" button to open page in new tab.</p>
</body>
</html>
I have a textarea that shows a random joke. I want the joke to post to Twitter using this link with the submit button: https://twitter.com/intent/tweet?text=
but I cannot for the life of me figure out how to get the text that's been generated in the textarea to be picked up in the link. I know there's an easy way to make this happen, but nothing I've tried has worked. Any help would be greatly appreciated!!! Here's the code I've got:
<form name="quoteForm">
<textarea wrap="virtual" name="quoteHere" rows="6" cols="40">Your joke is loading... unless your JavaScript is disabled
</textarea><br> <input type=button value="Previous" onClick="prevQuote();">
<input type=button value="Next" onClick="nextQuote();">
<input type=button value="Random" onclick="randQuote();"><br>
<p>
<input type="submit" value="Tweet This Joke"></p>
</form>
If you want to put the data in the query string then you need to make a GET request (which you are already doing), not a POST request (which you say you want to do).
If you want to send the data to https://twitter.com/intent/tweet then you need to put that URL in the action attribute of the <form> element. Since you have no action it will submit to the URL of your current page instead.
If you want the data to be associated with the query string parameter text then you need to name the textarea text and not, as you have, quoteHere.
The name attribute of textarea was changed from quoteHere to text.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form name="quoteForm" action="https://twitter.com/intent/tweet" onsubmit="submit();">
<textarea wrap="virtual" name="text" rows="6" cols="40">Your joke is loading... unless your JavaScript is disabled
</textarea><br> <input type=button value="Previous" onClick="prevQuote();">
<input type=button value="Next" onClick="nextQuote();">
<input type=button value="Random" onclick="randQuote();"><br>
<p><input type="submit" value="Tweet This Joke"></p>
</form>
</body>
</html>
I am making a Register - Login system in php/HTML and i have 3 php files now, in the first file (registering) worked FORM but in the second (login) not. The submit button don't do anything. What can be the problem?
<HMTL>
<HEAD><h1>Bejelentkezés</h1></HEAD>
<BODY>
<body background="http://wallpaperstock.net/minimal-gray-to-white-gradient_wallpapers_33797_1440x900.jpg"
<form action="afterlogin.php" method="post">
Felhasználónév: <input type="text" name="user2">
Jelszó: <input type="password" name="pass2">
<input type="submit" value="login">
</form>
</BODY>
</HMTL>
Try this...
<html>
<head><h1>Bejelentkezés</h1></head>
<body background="http://wallpaperstock.net/minimal-gray-to-white-gradient_wallpapers_33797_1440x900.jpg">
<form action="afterlogin.php" method="post">
Felhasználónév: <input type="text" name="user2">
Jelszó: <input type="password" name="pass2">
<input type="submit" value="login">
</form>
</body>
</html>
A lot of typo buddy...like HMTL..two body tags...plz do take care of what you write..and get some linting tool...
You have body tag two times in your code,please make it single and close tag is also not there,please add that.
I want to use the service provided at http://zxing.org/w/decode.jspx with a custom form in my own site. I've written the following code:
<html>
<body>
<FORM action="http://zxing.org/w/decode.jspx" method="post">
<INPUT type="text" name="u" value="http://justinsomnia.org/images/qr-code-justinsomnia.png">
<INPUT type="submit" value="Send">
</FORM>
</body>
</html>
When I submit the form, I'd expect to see the results page with a "Decode Succeeded" message. Instead, I see the original remote form I'm trying to duplicate.
Can you spot what's wrong with my custom form?
<html>
<body>
<FORM action="http://zxing.org/w/decode" method="get">
<INPUT type="text" name="u" value="http://justinsomnia.org/images/qr-code-justinsomnia.png">
<INPUT type="submit" value="Send">
</FORM>
</body>
</html>
You should use get instead of the post method. You are posting to the wrong URL, post to http://zxing.org/w/decode. I checked it, it's working now.
I have this piece of code:
<div>
<form name='profileForm' id='profileForm' action='' method='get'>
<input type='submit' name='ProfileBtn' id='ProfileBtn' class='buttonC' value='My Profile' />
</form>
<br />
<form name='logoutForm' id='logoutForm' action='' method='get'>
<input type='submit' name='LogOutBtn' id='LogOutBtn' class='buttonC' value='Logout' />
</form>
</div>
When I render the above the "profileForm" does not appear (although the profileBtn DOES appear).
the seconed form has no problems, which is weird because they are both similar.
It's probably an easy question but I have no idea what's the problem.
This just happened to me using Chrome -- it was because I had a form within a form. It looks like Chrome just stripped out the <form> open and close tag because my form was within another form. When I moved one form outside of the other, then both <form> tags were rendered in the html as intended.
Crackermann was getting at this in his answer too.
It's hard to give a direct solution without seeing your full html, but I'm guessing this is your problem - you need to make sure your form is not within another form. Really simple example to illustrate this:
Form within another form, notice if you run this code in Chrome and inspect <form id="form2"> is not rendered:
<html>
<head></head>
<body>
<form id="form1">
<div>form within a form</div>
<form id="form2">
<input type="text" placeholder="name" /><br/>
<input type="text" placeholder="title" />
</form>
</form>
</body>
</html>
If you move form2 outside of form1, run the code in Chrome and inspect, then <form id="form2"> is rendered:
<html>
<head></head>
<body>
<form id="form1">
<div>form2 moved outside of form1</div>
</form>
<form id="form2">
<input type="text" placeholder="name" /><br/>
<input type="text" placeholder="title" />
</form>
</body>
</html>
well then somehow there was a weird problem with the forms, the button didn't show up because when i ran the website the the 'profileForm' just disappeared somehow (and didn't show up in the console).
what i did was adding a third Form before 'profileForm' which somehow solved this.
There is an unclosed HTML TAG like < form > in your code before these lines ,
Find and close that form
OR
just put </form> before your code.
Just put a empty form on top of your form.
Then all forms will be appear with form id
<form></form>
<form name='profileForm' id='profileForm' action='' method='get'>
<input type='submit' name='ProfileBtn' id='ProfileBtn' class='buttonC' value='My Profile' />
</form>
<form name='logoutForm' id='logoutForm' action='' method='get'>
<input type='submit' name='LogOutBtn' id='LogOutBtn' class='buttonC' value='Logout' />
</form>
Check that you don't an unclosed form element before your next form open.
If you do, browsers will generate the source without displaying the subsequent form open and form close pair.
Try viewing your Page Source
For Mac users
Option + Command + U
For Windows users
Ctrl + U
Then check for any unclosed <form> tag above your specified <form> tag and close it.
It works for me, hope it works for you too