-1

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

Nik16
  • 3
  • 4

1 Answers1

0

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>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • then you need to look in the console. My code works. Inspect element and see it changes the action. Perhaps your free site removes all http links that goes elsewhere – mplungjan May 21 '17 at 07:40
  • ok it changes the action but for a strange thing the register page don't work with the form. i'll try to solve the problem. thanks! – Nik16 May 21 '17 at 07:49