Forum Moderators: coopster

Message Too Old, No Replies

form action a javascript function

         

ayushchd

5:30 pm on Jul 30, 2007 (gmt 0)

10+ Year Member



Hi I want my form to perform the same js function which is performed when the calculate button is clicked when the user hits enter instead of clicking on the calculate button. I tried the following but it doesn't work. Please help

<form name="form1" onSubmit="loader('validate', qty.value,company.value);">
<label class="left">Name Of Company : </label>
<select name="company" onChange = "callAjax(this.value);";>
<option selected>- -Select a company- -</option>
<? $query="SELECT * FROM listedcomp ORDER BY company";
$result = mysql_query($query);
$num = mysql_numrows($result);
for ($i = 0; $i < $num;) {
$row = mysql_fetch_assoc($result);
?>
<option value="<?=$row['company'];?>"><? echo $row['company'];?>;</option>

<? $i++; }
?>

</select>
<label class="left">Quantity : </label> <input type="text" name="qty"> <input type="button" name="Button" value="Calculate" onClick="loader('validate', qty.value,company.value);">
<label class="left"> <input type="button" name="Button" value="Buy" onClick="loader('buy',qty.value,company.value);"></div>
</div>
</fieldset>
</form>

joelgreen

6:26 pm on Jul 30, 2007 (gmt 0)

10+ Year Member



Not sure, but seems to me onSubmit should return true or false. Try this

<form name="form1" onSubmit="return loader('validate', qty.value,company.value);">

Note, in order to submit function "loader" should return true

ayushchd

6:35 pm on Jul 30, 2007 (gmt 0)

10+ Year Member



the answer is

<form onSubmit="loader('validate', this.qty.value, this.company.value);")

Please answer the other question of mine...ajax header...please