Jump to content

Onchange="form1.submit(); help keeps refreshing and losing data


xxsunshinegodxx

Recommended Posts

I have got a registration form requiring usual, name, address, username, email etc

Later on toward the end of the form it asks for country and then state. The country and states are stored in a database and the form queries the database for the states stored according to country. Trouble is that everytime I click on a country it refreshes the whole page and loses all the data that had been types in thus far...not only that but it doesn't select the state, just defaults back to please select a country.

 

The coding relevant to the form reads below.

<tr height="20">
<td class="tb_small"><b>Country :</b></td>
<td>  <select name="ud_cid" id="ud_cid" onChange="form1.submit(); "class="textfield">
<? getCountry($ud_cid); ?>
</select></td>
</tr>
<tr height="20">
<td class="tb_small"><b>State :</b></td>
<td>  <select name="ud_sid" id="ud_sid" class="textfield">
<? getState($ud_cid); ?>
</select></td>

I am guessingt hat it has got to do with the submit perhaps being similar to the submit button that I use to post the form with???

 

<br><input name="action" type="submit" class="btn" value="Join"><br><br> </td>

 

However, this is really frustrating and holding me back. ANy help on this would be greatly appreciated. Many thanks

Link to comment
Share on other sites

So is the onChange event to grab the states that are in the given country?

 

You will need to add some PHP so that when the country is chosen (and the form is subsequently submitted), the PHP checks for submission, and then builds a new form that has all the posted variables pre-loaded into the form fields.

 

so for example, the first_name field will become

<input type="text" name="first_name" size="25" value="<?php $_POST["first_name"] ?>">

 

Hope that helps..

 

Denno

Link to comment
Share on other sites

Thanks for the comments guys.

 

I know that I need to update the code in some ways as the site was designed in 2003 and so needs to come up to scope with the latest php version but this is bugging me as I am stuck.

 

Url is http://newquayuncovered.com/register/index.php

 

I am guessing the onchange is to get the states from the database but instead of just populating the next dropdown box with the states it is refreshing the whole page instead.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.