?
Solved

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

Posted on 2004-09-28
5
Medium Priority
?
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
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 …
Simple Linear Regression

719 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