Solved

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

Posted on 2004-09-28
5
223 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Has this question been answered??
0
 
LVL 3

Expert Comment

by:PodExpert
Comment Utility
I suppose so.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
A short article about problems I had with the new location API and permissions in Marshmallow
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now