Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image source with onClick event

Status
Not open for further replies.

fbloggs

Programmer
Jun 7, 1999
5
0
0
CA
I have following form, with an Image submit button:

<FORM name=&quot;orderinf&quot; ACTION=ONCLICK.pgm method=GET>
<input type=hidden name=&quot;TASK&quot; value=&quot;initial Value&quot;>
Type starting date: &nbsp;<input type=text name=&quot;inpdate&quot; value=&quot; &quot; size=10> (MMDDYYYY Format)
<INPUT align=bottom border=0 height=27 src=&quot;/websmart/images/parashoppingtxt.gif&quot; type=image width=20 onclick=&quot;document.orderinf.TASK.value='DUMMY';&quot;>
</FORM>

I expect the value for hidden field TASK to change to DUMMY, but it does not. It remains 'initial Value'. What am I doing wrong ?

Thanks for any help.
 
Although I have never tried this or troubleshooted this my first idea to try is to use &quot;innerHTML&quot; property. (IE ONLY solution at the moment but if it works it can be adapted). I assume you get &quot;initial Value&quot; when the form is processed by the action designated, yes? I think although your javascript seems to update the value when the form is submitted, only the hard-coded value (&quot;initial Value&quot;) is submitted, so try this...

Inbetween your <HEAD> and </HEAD> tags insert this:-


<script language=&quot;JavaScript&quot;>
function writeHiddenField()
{
document.orderinf.innerHTML += &quot;<input type=hidden name='TASK' value='DUMMY'>&quot;;
}
</script>


Then replace your FORM code with this:-


<FORM name=&quot;orderinf&quot; ACTION=ONCLICK.pgm method=GET>
Type starting date: <input type=text name=&quot;inpdate&quot; value=&quot; &quot; size=10> (MMDDYYYY Format)
<INPUT align=bottom border=0 height=27 src=&quot;/websmart/images/parashoppingtxt.gif&quot; type=image width=20 onclick=&quot;writeHiddenField();&quot;>
</FORM>


Remember, this is untested by me so likely to fail, I will try it my self when I get the time but if you try it and then come back here with the error I will try and suggest something else. Hey it might even work :)
Klae

You're only as good as your last answer!
 
I have tested your code by adding an alert to the end of the onclick and I see that the value is getting changed to DUMMY, try it and see what you get.

onclick=&quot;document.orderinf.TASK.value='DUMMY';alert(document.orderinf.TASK.value);&quot;

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top