Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

onchange and form.submit() does not work

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a problem trying to submit a form with an OnChange event on a Select. I'm running this in IE6. I tested my function to make sure it is called. But my form does not get submitted. Is this a problem with hidden variables on the form or not sure if the form is accessible to the function.

Any help would be appreciated ! Thanks!

Here are snippets of my code -
/**********************************************************************/

<html>
<head>
<title>New Order</title>

<script language="Javascript">

function displayFields()
{
var qty=document.orderForm.quantity.selectedIndex;
document.orderForm.submit.value = "0";
document.orderForm.num_selected.value = qty+1;
document.orderForm.dd_selected.value = "1";
document.orderForm.submit();
}

</script>

<table width="576" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>
<form method="post" action="ControllerServlet" name="orderForm">
<input type="hidden" name="cmd" value="NEW_ORDER" />
<input type="hidden" name="submit" value="1" />
<input type="hidden" name="dd_selected" value="0" />
<input type="hidden" name="num_selected" value="0" />
<table width="556" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td width="10%"> </td>
<td width="90%">
1) <span class="modComment">Quantity to Add:</span>
<select name="quantity" onchange="displayFields()" >
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
</select>
</td>
</tr>
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it work in browsers that have reasonable debugging tools?

Try it in Firefox. If it still doesn't work, check the javascript console for errors.
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does displayFields() get called at all?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code will never fire if the person wants 1 thing.

Eric
 
Jaya Chilakamarri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed my hidden variable name from "submit" to "submitform" and it is working. I guess it didn't like the name "submit".
Firefox is definitely more debugging-friendly, thanks for the tip !
 
Let nothing stop you! Not even this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic