how can I use html form for detect inserted language in input to translate to other language ?
Using Hebrew(iwrit)-English languages.
<form action="http://translate.google.com/translate_t" target="_blank">
<input type="text" name="text">
<input type="hidden" value="hp" name="prev">
<input type="hidden" value="iw" name="hl">
<input type="hidden" value="y" name="js">
<input type="hidden" value="" name="file">
<input type="hidden" value="iw" name="sl">
<input type="hidden" value="en" name="tl">
<input type="hidden" value="#" name="history_state0">
<input type="submit" value="Translate">
</form>
Assuming you need it to update live and not on a form submit, you will need to make some sort of request when the textbox to translate changes (http://api.jquery.com/change/), then make the appropriate changes to the form indicating the language.
As for the functionality itself, Google has an API for Translate (https://developers.google.com/translate/v2/libraries). There you will find a JavaScript interface, and that should handle all the heavy lifting for you.
I hope that helps.
Related
I have a question if we can submit an html post form with Linking in react-native. If yes how we can submit it?
I want to submit it to default browser (not with webview) and here is html form:
<form method="POST" target="..." id="..." :action="videoConferenceUrl">
<input type="hidden" name="target" value="..."/>
<input type="hidden" name="requestOrigin" value="..."/>
<input type="hidden" name="username" :value="..."/>
<input type="hidden" name="password" :value="..."/>
<input type="hidden" name="eventID" :value="..."/>
</form>
Please write every way how we can submit that form in the default browser.
Thanks in advance.
Can I change the redirect-on-success page that a user gets redirected to AFTER paying with a paypal generated button from the code?
I have this code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="sfdg#asdf.asdf">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="classes">
<input type="hidden" name="amount" value="99.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Literally just a form with a paypal button on it. Is there a way for me to set the redirect that button will go to after a user pays from the code? Maybe another hidden field?
The variable is called return, documented here. So you would need to add a hidden input and set the value to the URL you want.
This type of form is a horribly old Web 1.0 integration, however -- really only supported by PayPal for backwards compatibility on very old websites.
Why not switch to something modern?
I have some comment forms that I want to not be used unless the user is logged in with Google+. I initially have the "submit" button on my forms hidden by the CSS display:none property. I call javascript when the user logs in to change it back to display:inline.
Is this a valid way to prevent anonymous users from posting, or am I still vulnerable by leaving the rest of the comment form open for writing and whatnot...is there some clever way to submit the form without the submit button?
<form action="" method="post" name="form1" id="make">
<fieldset>
<legend id="makelegend">Log in to Post a Reference</legend>
<input type="hidden" name="loginname" id="loginname" />
<input type="hidden" name="logintype" id="logintype" />
<input type="hidden" name="loginspecial" id="loginspecial" />
<input type="hidden" name="reply" id="reply" value="0" />
<input type="hidden" name="identity" id="identity" value="<?php echo htmlspecialchars($_GET['pageno']); ?>" />
<p><label for="posneg">Positive or Negative?
<select name="posneg">
<option value="p">Positive</option>
<option value="n">Negative</option>
</select></label></p>
<textarea name="comment" rows="5" cols="70"></textarea>
<input type="submit" id="submitter" value="POST" style="display:none;" />
</fieldset>
</form>
It is ABSOLUTELY NOT safe! You're just not displaying the data to the user, but anyone who looks at the code can still find it - or just send the request manually. I can't stress this enough: ALWAYS use server-side validation! It's fine to validate things in the browser as well, but it's not a substitute for proper security measures.
I want to copy this input from page A and paste to page B
Let say this is Page A :
<input type="text" class="Name" id="cName" Value="Hey" readonly/>
<input type="number" class="Qty" id="cQty" Value="1" readonly/>
<input type="text" class="Price" id="cPrice" Value="10" readonly/><button class="" id="copy">Copy/?Add to Page B?</button>
This is Page B:
<ol><button class="" id="add">Add</button>
<li>
<input type="text" class="Name" id="pName" Value="" readonly/>
<input type="number" class="Qty" id="pQty" Value="" />
<input type="text" class="Price" id="pPrice" Value="" readonly/><button class="" id="cancel">Cancel</button>
</li><input type="text" class="Name" id="" Value="" readonly/>
<input type="number" class="Qty" id="tQty" Value="Total Quantity" readonly/>
<input type="text" class="Price" id="tPrice" Value="Total Price" readonly/></ol>
I read that I can't copy and paste, so is there another way of it? like adding Page A input text straight to Page B input text, like "add to shopping carts?"
Thanks for all the expert here.
If you have no option to use server-side programming, such as PHP, you could use the query string, or GET parameters.
In the form, add a method="GET" attribute:
<form action="b.html" method="GET">
<input type="text" name="serialNumber" />
<input type="submit" value="Submit" />
</form>
When they submit this form, the user will be directed to an address which includes the serialNumber (for example) value as a parameter. Something like:
http://www.example.com/display.html?serialNumber=XYZ
You should then be able to parse the query string - which will contain the serialNumber parameter value - from JavaScript, using the window.location.search value:
// from b.html
document.getElementById("write").innerHTML = window.location.search; // you will have to parse
// the query string to extract the
// parameter you need
See also JavaScript query string.
The alternative is to store the values in cookies when the form is submit and read them out of the cookies again once the b.html page loads.
See also How to use JavaScript to fill a form on another page.
You can take this value either by form post method or use browser cookies and very easy to implement.
And the methods varies as per your programming language.
I have a webpage with a div area. In this area, there can be two different forms.
It looks like this:
Form 1:
<div id="data" ...>
<form action="/action1" method="post">
<label for="label1">ID</label>
<input type="text" name="id" id="label1" value="" />
<label for="label2">Name</label>
<input type="text" name="name" id="label2" value="" />
<label for="label3">Description</label>
<input type="text" name="desc" id="label3" value="" />
<label for="label4">Address</label>
<input type="text" name="address" id="label4" value="" />
</form>
</div>
Form 2:
<div id="data" ...>
<form action="/action2" method="post">
<label for="label1">ID</label>
<input type="text" name="id" id="label1" value="" />
<label for="label2">Firstname</label>
<input type="text" name="first" id="label2" value="" />
<label for="label3">Lastname</label>
<input type="text" name="last" id="label3" value="" />
<label for="label4">Address</label>
<input type="text" name="address" id="label4" value="" />
<label for="label5">eMail</label>
<input type="text" name="mail" id="label5" value="" />
</form>
</div>
So there are two different forms. The values will be set with jQuery (Ajax call to the backend).
What is the best way to handle these two forms? Should I create two files with only the form and the load the form when they are needed? (Form 1 is needed if some clicks on button 1, form 2 is needed if someoe clicks on button 2 - the events are handled on client-side).
Or should I place both form into the single HTML file and enable or disable the form?
There's nothing stopping you have both forms in the HTML and conditionally hiding/showing the one that you want active. You're best bet is to give each form (or its containing div) a unique ID, and using this to show/hide using jQuery.
I think you should keep both the forms in the same page. And show/hide the required form as per the requirement.
Because if you keep the forms in separate HTML files, and user clicks on any button, then you'll have to make a XMLHttpRequest to get the HTML of form, whereas you can easily avoid this extra HTML request by including the HTML of the form in the same page.
I don't know if your website audience is so large or not. But saving a single HttpRequest should be very helpful.
See the article Minimize HTTP Requests by Yahoo developers. They clearly suggest to minimize HTTP requests.