• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

onchange and form.submit() does not work

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
does displayFields() get called at all?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !
 
Shiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic