change form submit location - javascript

i want to change location where form is submitted because i want that the user picks a domain but when i have submitted the form it didn't worked and when i have submitted the form without the dropdown it worked
my html:
<form method="post" action="http://order.Freehostnoads.usa.cc/register2.php" id="form1">
<table>
<tr><th style="text-align: left;">Free Subdomain<td><input type="text" name="username" size="30" maxlength="25" onkeyup="return ismaxlength(this)">
<select id="domain" size="1" onChange="javascript:chgAction()">
<option value="http://order.freehostnoads.usa.cc/register2.php" selected="selected">.freehostnoads.usa.cc</option>
<option value="http://order.3eehost.usa.cc/register2.php">.3eehost.usa.cc</option>
<option value="http://order.3eehosting.usa.cc/register2.php">.3eehosting.usa.cc</option>
<option value="http://order.3eehosting.igg.biz/register2.php">.3eehosting.igg.biz</option>
<option value="http://order.3eehost.igg.biz/register2.php">.3eehost.igg.biz</option>
<option value="http://order.3eehosting.flu.cc/register2.php">.3eehosting.flu.cc</option>
<option value="http://order.3eehost.flu.cc/register2.php">.3eehost.flu.cc</option>
<option value="http://order.3eehosting.nut.cc/register2.php">.3eehosting.nut.cc</option>
<option value="http://order.3eehost.nut.cc/register2.php">.3eehost.nut.cc</option>
<option value="http://order.fg.nut.cc/register2.php">.fg.nut.cc</option>
<option value="http://order.hs.igg.biz/register2.php">.hs.igg.biz</option>
<option value="http://order.pw.usa.cc/register2.php">.pw.usa.cc</option>
</select>
my javascript:
<script>
function chgAction(){
$('#form1').attr({'action':$('option:selected').attr('value')});
}
</script>
the website i want to put this on: http://freehostnoads.usa.cc/free-hosting-signup.php

This works (here at SO). I moved the event handler code out of the tag
Assigning prop or attr is .prop("name","value")
Perhaps your free site is removing your links. Have a look with "Inspect" and the console
$(function() {
$("#domain").on("change",function() {
$('#form1').prop('action',this.value);
});
}).change(); // initialise
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form method="post" action="http://order.Freehostnoads.usa.cc/register2.php" id="form1">
<select id="domain" size="1" >
<option value="">Please select</option>
<option value="http://order.freehostnoads.usa.cc/register2.php" selected="selected">.freehostnoads.usa.cc</option>
<option value="http://order.3eehost.usa.cc/register2.php">.3eehost.usa.cc</option>
<option value="http://order.3eehosting.usa.cc/register2.php">.3eehosting.usa.cc</option>
<option value="http://order.3eehosting.igg.biz/register2.php">.3eehosting.igg.biz</option>
<option value="http://order.3eehost.igg.biz/register2.php">.3eehost.igg.biz</option>
<option value="http://order.3eehosting.flu.cc/register2.php">.3eehosting.flu.cc</option>
<option value="http://order.3eehost.flu.cc/register2.php">.3eehost.flu.cc</option>
<option value="http://order.3eehosting.nut.cc/register2.php">.3eehosting.nut.cc</option>
<option value="http://order.3eehost.nut.cc/register2.php">.3eehost.nut.cc</option>
<option value="http://order.fg.nut.cc/register2.php">.fg.nut.cc</option>
<option value="http://order.hs.igg.biz/register2.php">.hs.igg.biz</option>
<option value="http://order.pw.usa.cc/register2.php">.pw.usa.cc</option>
</select>
<form>

Related

Changing the language of menu items

I'm trying to add a new locale and the language change option to a menu I created.
Below you can see the code that I have my progress so far
Essentially, I'd like the menu items for "sports" and "districts" to change to Chinese after the radio button for "中文“ is clicked. My JavaScript skill is very low so I'm having problems making this happen. Since it's a short list and I can write Chinese without problem, I thought there may be a simple fix, but so far I haven't made any progress. Any suggestions on how to go about this is much appreciated.
<body>
<form action="">
<input type="radio" name="language" value="english">English<br>
<input type="radio" name="language" value="chinese">中文<br>
</form>
</body>
<b>Find your sport</b>
<form>
<select name="Sports">
<option value="basketball">Basketball</option>
<option value="football">Football</option>
<option value="badminton" selected>Badminton</option>
<option value="table tennis">Table Tennis</option>
<option value="swimming">Swimming</option>
<option value="billiards">Billiards</option>
<option value="archery">Archery</option>
<option value="baseball">Baseball</option>
<option value="bowling">Bowling</option>
<option value="climbing">Climbing</option>
<option value="darts">Darts</option>
<option value="fencing">Fencing</option>
<option value="golf">Golf</option>
<option value="squash">Squash</option>
<option value="tennis">Tennis</option>
</select>
</form>
<b>Find your district</b>
<form>
<select name="Districts">
<option value="xuhui">Xuhui</option>
<option value="jingan">Jingan</option>
<option value="huangpu" selected>Huangpu</option>
<option value="changning">Changning</option>
<option value="pudong">Pudong</option>
<option value="putuo">Putuo</option>
<option value="hongkou" selected>Hongkou</option>
<option value="yangpu">Yangpu</option>
<option value="minhang">Minhang</option>
<option value="songjiang">Songjiang</option>
<option value="qingpu" selected>Qingpu</option>
<option value="jiading">Jiading</option>
<option value="baoshan">Baoshan</option>
<option value="fengxian">Fengxian</option>
<option value="jinshan" selected>Jinshan</option>
<option value="chongming">Chongming</option>
</select>
</form>
<form method="post" name="form1" id="form1">
<input id="submit" name="submit" type="submit" value="Submit" onclick="getVenues();" />
</form>

Popup Confirm box on Select change

I have HTML form with SELECT field and when i choose option i would like to launch CONFIRM message and if i choose "yes" it should submit the form.
how can i do that?
<form action="index.php?page=<?PHP echo $_GET['page'] ?>" method="post" >
<select name="planID" onChange="this.form.submit()" class="form-control">
<option value="">Choose plan1</option>
<option value="">Choose plan2</option>
<option value="">Choose plan3</option>
</select>
</form>
HTML:
<form action="index.php?page=<?PHP echo $_GET['page'] ?>" method="post" id="myForm">
<select name="planID" onchange="if(confirm('Are you sure?')) document.getElementById('myForm').submit();" class="form-control">
<option value="">Choose plan1</option>
<option value="">Choose plan2</option>
<option value="">Choose plan3</option>
</select>
</form>

how to add up values with same textfield name attribute

Hello I have two select menus, that contain values, my intention is to multiple the values of the two select menus and show them in a TextField,
I've done this successfully carried this out by doing this :
<script type="text/javascript"><!--
function updatesum() {
document.form1.textfield3.value = (document.form1.selectt.value -0) * (document.form1.selecttt.value -0);
}
//--></script>
<form id="form1" name="form1" method="post" action="val.php">
<label><strong><br />
Chelsea vs Arsenal</strong>
<select name="selectt" onchange="updatesum()">
<option value="0">select</option>
<option value="100">100</option>
<option value="200">200</option>
</select>
</label>
<label><strong>odds</strong>
<select name="selecttt" onchange="updatesum()">
<option value="0">select</option>
<option value="100">L</option>
<option value="200">W</option>
<option value="400">D</option>
</select>
</label>
<input name="textfield3" type="text" /><br />
</form>
Now I'm trying to do a double of this select menus using the same name attribute, but it refuses to calculate.
This is what I'vve tried :
document.form1.textfield3.value = (document.form1.selectt.value -0) * (document.form1.selecttt.value -0) }
//--></script>
<form id="form1" name="form1" method="post" action="val.php">
<label><strong><br />
Chelsea vs Arsenal</strong>
<select name="selectt" onchange="updatesum()">
<option value="0">select</option>
<option value="100">100</option>
<option value="200">200</option>
</select>
</label>
<label><strong>odds</strong>
<select name="selecttt" onchange="updatesum()">
<option value="0">select</option>
<option value="100">L</option>
<option value="200">W</option>
<option value="400">D</option>
</select>
</label>
<input name="textfield3" type="text" /><br /> <label><strong><br />
Chelsea vs Arsenal</strong>
<select name="selectt" onchange="updatesum()">
<option value="0">select</option>
<option value="100">100</option>
<option value="200">200</option>
</select>
</label>
<label><strong>odds</strong>
<select name="selecttt" onchange="updatesum()">
<option value="0">select</option>
<option value="100">L</option>
<option value="200">W</option>
<option value="400">D</option>
</select>
</label>
<input name="textfield3" type="text" /><br />
</form>
I was hoping it would work this way, but it didn't, how can I achieve this?
I didn't understand what you are trying to say but i have write some pseudocode hope this will help you...
pseudocode
<script>
var globalVariable=1;
function updateSum(){
//get current element value
globalVariable*=document.form.select.value
textfield.value = globalVariable;
}
</script>

Chaining an input option after a select?

I'm wondering how I can chain an input box after chaining a selection in my form.
I'm using http://www.appelsiini.net/projects/chained to chain my selects and it works. However, I need to adjust this to also allow for the chaining of an input. In the below example it would be someone would choose an option such has an item has Strength on it then the select menu of value options then input the value. I'm trying to also incorporate into this where after those 3 options of item, controller, value are inputed the user has the option to filter more so another box appear with the same options of strength, agility, etc. http://jsfiddle.net/isherwood/XMx4Q/ is an example of work I used to incorporate this into my own work.
<form id="myform" name="myform" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div>
<label for="searchterm">Name:</label>
<input type="text" name="searchterm">
</div>
<div>
<div class="chainedSelectFilter">
<select name="specificFilter" class="attribute">
<option value="" selected>Select a Filter</option>
<option value="strength">Has Strength</option>
<option value="agility">Has Agility</option>
<option value="spirit">Has Spirit</option>
<option value="stamina">Has Stamina</option>
</select>
<select name="specificFilter" class="valueController">
<option value=">" selected>></option>
<option value=">=">>=</option>
<option value="=">=</option>
<option value="<="><=</option>
<option value="<"><</option>
</select>
</div>
</div>
</div>
<div>
<label for="submit"></label>
<input type="submit" name="submit" value="Filter">
</div>
Code reference below shows how to accomplish this. Here is jsFiddle that shows it's working.
HTML
<form id="myform">
<div class="container">
<select>
<option value=""></option>
<option value="one">one</option>
<option value="two">two</option>
</select>
<input type="text" class="chain" value="" placeholder="Type here"/>
</div>
<div class="container">
<select>
<option value=""></option>
<option value="one">one</option>
<option value="two">two</option>
</select>
<input type="text" class="chain" value="" placeholder="type here"/>
</div>
<div class="container">
<select>
<option value=""></option>
<option value="one">one</option>
<option value="two">two</option>
</select>
<input type="text" class="chain" value=""/>
</div>
</form>
JS
$('select').change(function () {
$(this).next('input').fadeIn();
});
$('body').on('keyup','input.chain',function () {
$(this).parent().next('div').fadeIn();
});

Show submit button on multiple forms only if option selected

I need to show the submit button on many forms on the same page only if one option from a select is selected.
I have:
<form id="1">
<input type="text">
<select>
<option value="">Select one value</option>
<option value="1">value 1</option>
<option value="2">value 2</option>
</select>
<input type="submit">
</form>
and
<form id="2">
<input type="text">
<select>
<option value="">Select one value</option>
<option value="1">value 1</option>
<option value="2">value 2</option>
</select>
<input type="submit">
</form>
so, I need to show the submit button only if an option of the select is selected
Thanks!!!
This a working example with you html http://jsfiddle.net/g188o5eg/
$('select').on('change', function(){
if($(this).val() != ''){
$(this).parent().find('input[type="submit"]').show();
} else {
$(this).parent().find('input[type="submit"]').hide();
}
});
It will work with all forms on your site :)
Try something like this (would work with multiple select boxes (uses the nearest submit):
<form>
<input type="text">
<select class="select">
<option value="">Select one value</option>
<option value="1">value 1</option>
<option value="2">value 2</option>
</select>
<input type="submit" class="submitbutton">
<script type="text/javascript">
$('.submitbutton').hide();
$('.select').click(function() {
$(this).closest('.submitbutton').show();
});
</script>

Categories

Resources