Solved

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

Posted on 2004-09-28
5
242 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

776 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