Author |
Topic  |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 26 June 2001 : 13:47:21
|
I have a hidden input field that when the preview button is clicked, i want it to set the value of the hidden field to something different. here is the example....
<SCRIPT LANGUAGE="JavaScript"> function CreatePreview(){ document.PostCode.Preview.value="yes"; document.PostCode.submit(); } </script> <form action="segments_admin.asp" method="post" name="PostCode"> <input type="hidden" name="Preview" value="no"> <input name="Preview" type="button" value=" Preview " onclick="CreatePreview()"> </form>
it submits the form fine, but does not change the value, any ideas?
Brad |
|
HuwR
Forum Admin
    
United Kingdom
20595 Posts |
Posted - 26 June 2001 : 14:17:13
|
trying changing the name of your form element to something other than Preview
|
 |
|
tilttek
Junior Member
 
Canada
333 Posts |
Posted - 26 June 2001 : 15:03:49
|
quote:
I have a hidden input field that when the preview button is clicked, i want it to set the value of the hidden field to something different. here is the example....
<SCRIPT LANGUAGE="JavaScript"> function CreatePreview(){ document.PostCode.Preview.value="yes"; document.PostCode.submit(); } </script> <form action="segments_admin.asp" method="post" name="PostCode"> <input type="hidden" name="Preview" value="no"> <input name="Preview" type="button" value=" Preview " onclick="CreatePreview()"> </form>
Hum, there is a bug with NS4.x so try using this instead:
<SCRIPT LANGUAGE="JavaScript"> function CreatePreview(){ document.PostCode.Preview.value="yes"; setTimeout("document.PostCode.submit()", 10); } </script> <form action="segments_admin.asp" method="post" name="PostCode"> <input type="hidden" name="Preview" value="no"> <input name="PreviewButton" type="button" value=" Preview " onclick="CreatePreview()"> </form>
And you hade two object with the same name!
Philippe Gamache http://www.tilttek.com http://www.lapageamelkor.com |
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 26 June 2001 : 15:25:07
|
thanks, it worked GREAT
Brad |
 |
|
tilttek
Junior Member
 
Canada
333 Posts |
|
HuwR
Forum Admin
    
United Kingdom
20595 Posts |
Posted - 27 June 2001 : 10:07:45
|
quote:
quote:
thanks, it worked GREAT
Never forget to use the SetTimeout, cause of a bug in Netscape.
Philippe Gamache http://www.tilttek.com http://www.lapageamelkor.com
Is this something we should therfore fix in the Snitzcode, there are quite a few uses of the javascript submit function
|
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 27 June 2001 : 10:58:35
|
is the 10 the amount of seconds to wait before submiting? setTimeout("document.PostCode.submit()", 10);
should it be set to 1 instead? setTimeout("document.PostCode.submit()", 1);
quote:
quote:
thanks, it worked GREAT
Never forget to use the SetTimeout, cause of a bug in Netscape.
Philippe Gamache http://www.tilttek.com http://www.lapageamelkor.com
Brad |
 |
|
tilttek
Junior Member
 
Canada
333 Posts |
Posted - 28 June 2001 : 08:58:52
|
quote:
is the 10 the amount of seconds to wait before submiting? setTimeout("document.PostCode.submit()", 10); should it be set to 1 instead? setTimeout("document.PostCode.submit()", 1);
No 10 seconds would be 10000... It's Millisecond.
Philippe Gamache http://www.tilttek.com http://www.lapageamelkor.com |
 |
|
big brother
Starting Member
27 Posts |
Posted - 28 June 2001 : 09:28:43
|
Alternately you could always try this!
<SCRIPT LANGUAGE="JavaScript"> function CreatePreview(){ document.PostCode.Preview.value="yes"; document.PostCode.submit(); } </script>
<form action="segments_admin.asp" method="post" name="PostCode"> <input type="hidden" name="Preview" value="no"> <a href="javascript:CreatePreview();">preview</a> </form>
|
 |
|
|
Topic  |
|