upload file and text in loopback - loopbackjs

Hello guys i m new too loopback, so don't know if it is possible or not
<form>
<input type="text" id name="product">
<input type="text" id name="productdesc">
<input type="file" id name="product">
</form>
Demo image of form:
This demo form i m try to save to database using model rest api (model named as product)
Note: just try to save input text field and file path url. i have created a container, using container i can easly upload a file to folder name as storage/file inside server folder. hHow I can do that? Any suggestion would be great

Related

how can i send a small data like a url to the new tab that a chrome extension opens?

So i have the following code that upon clicking the button opens the localhost main html file where flask app.py is running on flask server
$("#startbutton").click(function(){
chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function
(tabs) {
urlPresent = tabs[0].url;
//var myWindow = window.open("http://localhost:3000/", "_blank");
//myWindow.document.write("<h1> urlPresent</h1> "+urlPresent);
window.open('http://localhost:3000/', '_blank');
});
flask server is running at http://localhost:3000/
Now i have url of the active website, is there any way i can send this urlPresent variable to the new tab that opens from this button #startbutton to the html file on server whose code is
<form action="{{url_for('scrap')}}" method="post" id="theform">
<b>
Enter Review:
<input type="text" name="reviewfield" value="" id="inputfield"
/></b>
<br />
<br />
<input type="submit" value="Scrap and Predict" />
</form>
</center>
and set it to the value of the form input type text.
PS: I have the webpage that is automatically populated with the url (with the help of chrome extension - i know it would be simpler to just copy the url but my professor wants me to automate it) which is then scrapped and feeded into the classifier and then the results are returned.

send message from textarea to determined email address with python in web2py

{{extend 'layout.html'}}
<h1>Send Email</h1>
<form method='post'>
<input type='text' name='name'/>
<input type='text' name='email'/>
<input type='text' name='subject'/>
<textarea rows="6" name="message" cols="31"></textarea></p>
<input type='submit' value='Send' />
</form>
<h3>
Email sent {{=}}
</h3>
I created one textbox, one text area and one button for sending Email in view section in web2py. I want to create UI area. user should write name and text and after clicking on SEND button those name and text should be sent to an specific email address. I am a beginner in python and I need your help for writing related code in controller section and maybe other codes in view section.
I just have this code in the page Email.html on view section but I didn't know what should I write here--> {{=}}
moreover I don't have any code in controller!

create a html form with 2 action pags

How can i create a html form that action attribute have 2 destination.I want when user click on submit bottom , check if user entered wrong data the page goes to another pages with window.location and if user insert the correct input goes to main page with the same instruction.
First of all, what do you mean by correct input?
Main form data validation occurs in server side, not client side. you'd better use client side just for simple verification, like for typos.
There is no need for 2 destination pages (as you call it so).
You may use the standard action attribute which is the page on the server to which you are sending your form data.
there, You have the option to decide which condition needs what action and send the data (and then the user) to the desired page / action.
Sample code for the form
<form id='myform' action='action.php' method='POST' target='formresponse'>
<label for='name' >Your Full Name*: </label><br/>
<input type='text' name='name' id='name' maxlength="50" /><br/>
<label for='email' >Email Address*:</label><br/>
<input type='text' name='email' id='email' maxlength="50" /><br/>
<input type='button' name='Submit' value='Submit' />
</form>
<iframe name='formresponse' width='300' height='200'></frame>
Multiple action
function SubmitForm()
{
document.forms['contactus'].action='action1.php';
document.forms['contactus'].target='frame_result1';
document.forms['contactus'].submit();
document.forms['contactus'].action='action2.php';
document.forms['contactus'].target='frame_result2';
document.forms['contactus'].submit();
return true;
}

Shopify Remote add to cart - Same variant id, different properties but yet the Shopify cart considers them the same

I am using the Shopify remote add to cart form to pass a group of customized products. Same Shopify product (variant-id), different custom designs (line item properties).
The form call treats the 3 customized products that I am adding to the cart as identical even though they have distinct line items. If I push this to the Shopify cart I will see a product with a quantity of 3. If I submit a form for each product individually then it treats them as unique products in the cart which is the behavior I would hope for.
Here is and example of the code I am trying to use (Notice the "Customizer#" and "Your Design" is unique for each product):
<form action="http://www.boardlams.com/cart/add" method="post">
<input name="id[]" value="262542038" type="hidden">
<input id="Customizer#" name="properties[Customizer#]" value="RTD-Design-1" type="hidden">
<input id="YourDesign" name="properties[YourDesign]" value="http://designer.realtimedesigner.com/orders2/153000/153500/153561/3/design_1.png?1355818798" type="hidden">
<input name="id[]" value="262542038" type="hidden">
<input id="Customizer#" name="properties[Customizer#]" value="RTD-Design-2" type="hidden">
<input id="YourDesign" name="properties[YourDesign]" value="http://designer.realtimedesigner.com/orders2/153000/153500/153561/3/design_2.png?1355818798" type="hidden">
<input name="id[]" value="262542038" type="hidden">
<input id="Customizer#" name="properties[Customizer#]" value="RTD-Design-3" type="hidden">
<input id="YourDesign" name="properties[YourDesign]" value="http://designer.realtimedesigner.com/orders2/153000/153500/153561/3/design_3.png?1355818798" type="hidden">
<input name="return_to" value="/cart" type="hidden">
<input value="Many Customized Products" type="submit">
</form>
Is there a way to have the Shopify cart consider each product as separate item in the cart when submitting the form this way? Sending a remote add to cart form per customized project is not a good solution in this case because we want to submit all of the products as a group.
I appreciate any insights!
Regards,
John

Additional POST data for django

I'm using Django and I am having trouble passing variable information back to the server without modifying the url. Here's what I have which works the way I want except that I want the action to be /foo:
<form method="post" action="/foo/{{ variable }}">
<input type="submit" value="bar"/>
</form>
When I do this I can easily get the variable when I parse the url. Instead, I want to add the variable to the POST QueryDict. Is this possible?
Yes. just add additional input fields:
<form method="post" action="/foo/">
<input type="hidden" value="{{ variable }}" name="name_of_var">
<input type="submit" value="bar"/>
</form>
Then you can access the variable in the view by:
request.POST['name_of_var']
or if you are not sure if the variable exists. This will not raise exception is does not exist.
request.POST.get('name_of_var')
Just make an input inside your form:
<input type="hidden" value="{{ variable }}" name="foo" />
Then on a view:
foo = request.POST.get('foo', None)
Also, I recomend you to use url tag for action.
Simply add a hidden input element with the name and value you need like so:
<input type="hidden" name="varname" value="myvalue" />
Can you not make the variable an input field in the form? You can make it hidden to avoid overriding it. This will post the data in the submit and achieve what you want.
Isn't this what the Django sessions framework is for? You can pass data back and forth without trying to pass it through a url.
The session framework lets you store and retrieve arbitrary data on a per-site-visitor basis. It stores data on the server side and abstracts the sending and receiving of cookies.
https://docs.djangoproject.com/en/1.5/topics/http/sessions/