Window.close script doesn't seem to close - html

Having trouble getting this code to actually close a window. Can anyone help? When the "return" is clicked it just goes to a blank page.
<form method="post" action="http://ww8.aitsafe.com/cf/add.cfm" target="newWindow" onsubmit="window.open('', 'newWindow','width=800,height=500,'+'scrollbars=yes,status=no,toolbar=no,menubar=no,top=200,left=200')">
<p>
<input type="hidden" name="userid" value="A8403475">
<input type="hidden" name="return" value="window.close">
<input type="hidden" name="thumb" value="logo.png">
<select name="productpr">
<option>- Select Size -</option>
<option value="Size one:9.99">Size one - 9.99</option>
<option value="Size two:12.99">Size two - 12.99</option>
</select>
<input type="submit" value="Add to Cart">
</p>
</form>

Defining your code as a value of hidden input field will do nothing in this case.
Create a button and do something similar to this: <button type="button" onclick="window.close();">Close</button>
You didn't specify when you want the window to be closed...

Related

I'm trying to auto-populate an email form using HTML only

Everything looks fine except for the body part. If a user enters "Grab a beer with you", the body of the email would show "Grab+a+beer+with+you". How do I get the body to be just a space instead of a +. I'm also confused on what I should be using, some places say it should be a POST, but GET works, POST doesn't. Anyways, here is my code.
<form enctype="text/plain" method="GET" action="mailto:{rudyg#hotmail.com}?subject=Subject&body=Body">
<div class="form-group">
<label for="exampleSelect1">What is this in regards to?</label>
<select class="form-control" id="exampleSelect1" name="subject" value="Subject">
<option value="Job opportunity">Job opportunity</option>
<option value="Question about myself or my code">Question about myself or my code</option>
<option value="General Question">General Question</option>
<option value="">No subject</option>
</select>
</div>
<div class="form-group">
<label for="exampleTextarea">What would you like to say?</label>
<textarea class="form-control" id="exampleTextarea" name="body" value="Body" rows="4" placeholder="I'd like to speak with you about an exciting job opportunity."></textarea>
</div>
<button type="submit" class="btn btn-primary" name="submit" value="Submit">Submit</button>
</form>
Sorry, I meant to say that I also tried the enctype="text/plain", but it still gives me pluses in the body of the email.
change the enctype attribute in the form tag to text/plain , Like :
enctype="text/plain"

Passing multiple values in JSP url

I am trying to pass multiple values in a JSP page url to another one.
The code is:
<form name="QuantityForm" onsubmit="return quantityValidation()" action='<%="basket.jsp?addItem="+product.PID%>' method="post">
Quantity <input type="text" name="quantity" size="5">
<input class="button button2" type="submit" value="Add to basket" />
</form>
How do i pass the value of quantity(the field of name="quantity") in the same URL? i know it's something like "Search.jsp?item=<%=search%>&item2=value2&item3=value3.." but i can't seem to structure it properly. Thanks
Do not put your ? and parameters in the action url. Put your parameters in input tags:
<form name="QuantityForm" onsubmit="return quantityValidation()" action='basket.jsp' method="post">
<input type="hidden" name="addItem" value="%product.PID%">
Quantity <input type="text" name="quantity" size="5">
<input class="button button2" type="submit" value="Add to basket" />
</form>
you're using method="post" which doesn't allow parameters to be passed into the url. change it to method="get" if you want the parameters to be passed along with the url.

get value of select element when submitting form

I have this HTML form:
<form id="form1">
<select name="date" class="form-control">
</select> <input type="submit" name="submit" id="submit" value="Save" onclick="SubmitForm('#form1', 'editcustomer_callusage.php?date=', '.EditCustomer');" class="btn btn-default" />
</form>
how can i put the selected value in the date select element into the onclick function on the button?
I think this is what you're looking for...
$('#submit').click(function () {
var d = $('[name=date]').val()
});
Not completely sure the whole '[name=date]' thing will work, if it doesn't just give the date an ID and find it the same way you found submit.
Lemme know if this works for ya!

how to include directions in iframe

I have the following form:
<form method="get" action="http://maps.google.com/maps" target="_blank">
<select name="daddr">
<option selected value="Bovetstrasse 1, 3012 Bern, Switzerland">Missione (a Berna)</option>
<option value="">Zollikofen</option>
<option value="">Bümpliz</option>
<option value="">Ostermundigen</option>
<option value="">Münsingen</option>
<option value="">Konolfingen</option>
<option value="">Worb</option>
</select>
<input type="text" name="saddr" maxlength="255" value="">
<input type="hidden" name="hl" value="it">
<input type="hidden" name="z" value="15">
<input type="hidden" name="t" value="m">
<input type="hidden" name="layer" value="t">
<input type="hidden" name="doflg" value="ptk">
<!--input type="hidden" name="output" value="embed"-->
<button type="submit">Guidami</button>
<p class="Didascalia">Powered by Google</p>
</form>
It opens a new window with the map and the directions on the left side as usual.
What I would like to do is to open this content in an iframe that I have in the same page but
if I symply change the target to the iframe name, I get an error (This content cannot be displayed in a frame. To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.)
if I also un-comment the output=embed parameter, then only the map is shown with the route but no listing of directions
Does any-one know how to do this?

html input action through button

I am using the following form to take input and then set an action
<select name="page_option">
<option value="go1">GO1</option>
<option value="go2">Go 2</option>
</select>
<input type="submit" value="Change home.php" />
Instead of this I want to have two buttons side by side,one button has text GO1 while other has GO2 and when user click GO1 and GO2 it will serve the same purpose as this above form
Also when Go1 button is clicked the page will display below the buttons "GO1 is on" and when Go2 is clicked it will display below "GO2 is on"
Any clue ?
Try the following..
<form action='action.php' method='post'>
<input type="submit" name='go1' value="go1">
<input type="submit" name='go2' value="go2">
in action.php
if(isset($_REQUEST['go1']))
{
$_SESSION['msg'] = 'Go1 button is on'
}
if(isset($_REQUEST['go2']))
{
$_SESSION['msg'] = 'Go2 button is on'
}
print_r($_SESSION['msg']);
Hope this will help you. You must start session at the beginning of action.php file
Thanks
You can have two submit buttons, as follows:
<input type="submit" value="go1">
<input type="submit" value="go2">
You can check serverside which button was clicked, and lead the user to the appropriate page.
<form action="form_action.asp" method="get">
<select name="page_option">
<option value="go1">GO1</option>
<option value="go2">Go 2</option>
</select>
<input type="submit" value="Submit" />
</form>
action="form_action.asp" method="get"
then use java script
<input type="submit" onclick="function1()" value="go1">
<input type="submit" onclick="function2()" value="go2">
funcation f1(){}
funcation f2(){}