How to get form to submit???

G

Greg Scharlemann

I have some php code to handle the following form is submitted, but
because there are two places the form submits I get an error. If the
drop down changes, the php code will grow the number of city/state
combinations, if the button is clicked the data is added to the
database. Perhaps there is a better way to grow the number of
city/state combinations while still retaining any text previously typed
into the input boxes?

Thanks for your help!

<html>
<body>
<table border="0">
<form method="post" action="test.php">
<tr>
<td colspan="4">Define up to 50 City/State
combinations.<br/><br/></td>
</tr>
<tr>
<td colspan="4">Insert
<select name="showCity" onchange="submit()" >
<option selected value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
</select> Cities:<br/>
</td>
</tr>
<tr>
<td>City:</td>
<td>&nbsp;<input type="text" name="city0" size="20" value=""
maxlength="100" /></td>
<td align="right">&nbsp;&nbsp;&nbsp;<b><u>State</u>:</b></td>

<td>
<select name="state0" size="1" >
<option value=""></option>
<option value="AK">AK</option>
<option value="AL">AL</option>
<option value="AR">AR</option>
<option value="AZ">AZ</option>

<option selected value="CA">CA</option>
</select>
</td>
</tr>
<tr>
<td colspan="4" align="center"><br/>
<input type="submit" name="submit" value="Add" />
</td>
</tr>
</form>
</table>
</body>
</html>
 
D

David Dorward

Greg said:
I have some php code to handle the following form is submitted, but
because there are two places the form submits I get an error.

An error? WHAT error?
<table border="0">
<form method="post" action="test.php">

Your HTML is invalid. http://validator.w3.org/
<select name="showCity" onchange="submit()" >

window.submit() is undefined by default, and you don't define it in
your code.

Possibly you want to call it as a method of a form element?
 
A

ASM

Greg Scharlemann a écrit :
I have some php code to handle the following form is submitted, but
because there are two places the form submits I get an error. If the
drop down changes, the php code will grow the number of city/state
combinations, if the button is clicked the data is added to the
database. Perhaps there is a better way to grow the number of
city/state combinations while still retaining any text previously typed
into the input boxes?

Thanks for your help!

<html>
<body>
<table border="0">

what does do here this form tag outside regular way of html flux ?
<form method="post" action="test.php">
<tr>
<td colspan="4">Define up to 50 City/State
combinations.<br/><br/></td>
</tr>
<tr>
<td colspan="4">Insert
<select name="showCity" onchange="submit()" >

onchange="this.form.submit()"

onchange="submit.click();"
(it would have been much more better to haven't named your submit-button
'submit' ... ! )
<option selected value="1">1</option>
<option value="2">2</option> .../...
<option value="50">50</option>
</select> Cities:<br/>
</td>
</tr>
<tr>
<td>City:</td>
<td>&nbsp;<input type="text" name="city0" size="20" value=""
maxlength="100" /></td>

why with an align=right do you need those spaces ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top