What about this scenario ???
My form MUST have 3 input types with the same name but different values. At the moment I have this working using "<input type=submit...." However I want to change the button to an image. Unfortunately the "<input type=image..." does not support the "value" attribute for "<input type=image value=somevalue..." under Netscape.
The code I have determines the next course of action, once the form is submitted, based on the values contained and submitted within the input of the form.
Suppose I do use the setup as follows
<form action=...>
<A href=javascript:document.submit()><img src=...>
<type=hidden name=myname value=act1>
</a>
<A href=javascript:document.submit()><img src=...>
<type=hidden name=myname value=act2>
</a>
<A href=javascript:document.submit()><img src=...>
<type=hidden name=myname value=act3>
</a>
</form>
When this is submitted the value "act3" will always be picked up. If the hidden types have the same name the last value encountered (associated with this name) is "inherited" and sent through.
The other option I tried was:
function changeval_1(){
.........
document.test.myname.value = 'cancel_message';
.....}
function changeval_2(){
.........
document.test.myname.value = 'save_message';
.....}
function changeval_3(){
.........
document.test.myname.value = 'send_message';
.....}
<form action=.... name=test method=POST>
<type=hidden name=myname value=" ">
<a href=javascript:document.submit() onclick=changeval_1()><img src=...></a>
<a href=javascript:document.submit() onclick=changeval_2()><img src=...></a>
<a href=javascript:document.submit() onclick=changeval_3()><img src=...></a>
</form>
Again this doesn't work. The value icked up by the form will be " " or nothing. It seems that in this case the value " " is asociated with the variable and can't be changed with the Javascript. I have noticed that the Javascript does change the value locally but when the form is submitted the global value that should be set by the Javascript isn't retained. Instead, the first value encountered, i.e. " " is sent across. How can I send this value across so that I can grab it within PHP.
Anyone have any ideas?
This is really getting to me.
Any info. greatly appreciated.
Slan,
Dougie.
Richard A. Rijnders wrote:
You can create hidden variables in your form and, prior to the post operation, set the value of the variable to your javascript variable value:
document.myForm.myVar.value = myScriptVar;
-- Rich Rijnders
-- Irvine, CA US