Solved

URGENT :::: simple javascript question, I need to change the hidden tag from button push 500points

Posted on 2004-09-28
5
250 Views
Last Modified: 2010-04-17
I need to chage this

<input type="hidden" name="pid" value="updateItem" />

to whatever i want from this button push ..


<input type="submit" value="Delete Item" /> <<< this code can not be changed


0
Comment
Question by:Caiapfas
5 Comments
 
LVL 9

Expert Comment

by:Rodney Helsens
ID: 12174483
not sure what you mean by <<this code cannot be changed, but I will assume that you mean you cannot attach an event handler to that button, is this case, you can use the OnSubmit() event of the form to access this hidden field and set its value.


<script>
function dosomething()
{
document.forms["myform"].pid.value = "whatever I want";
}
</script>

<form name="myform" onSubmit="dosomething();">

<input type="hidden" name="pid" value="updateItem" />

<input type="submit" value="Delete Item" />

</form>
0
 
LVL 2

Author Comment

by:Caiapfas
ID: 12174525
yes the event handler can be in the button and has to be since there are 5 buttons on this page..pleaseh help asap
0
 
LVL 3

Accepted Solution

by:
PodExpert earned 500 total points
ID: 12177152
I am not sure if I understand, but I suppose you want to change the value of the hidden tag by a button push. In this case, you can do it in the following way:

<script>
function change_value(value)
{
document.forms["myform"].pid.value = value;
}
</script>

<form name="myform" onSubmit="dosomething();">

<input type="hidden" name="pid" value="updateItem" />

<input type="submit" value="Delete Item" />

<button onClick="change_value('first_value');">First button</button>
<button onClick="change_value('second_value');">Second button</button>

</form>

The above code uses ordinary buttons (no input tags, hance you can't use the onClick handler for them) to change the value of the hidden tag.

Good luck.
P.
0
 
LVL 11

Expert Comment

by:raj3060
ID: 12190211
Has this question been answered??
0
 
LVL 3

Expert Comment

by:PodExpert
ID: 12190638
I suppose so.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question