Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

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

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
Caiapfas
Asked:
Caiapfas
1 Solution
 
Rodney HelsensCommented:
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
 
CaiapfasAuthor Commented:
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
 
PodExpertCommented:
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
 
raj3060Commented:
Has this question been answered??
0
 
PodExpertCommented:
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now