Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send javascript variable via html form

Status
Not open for further replies.

hazelsisson

Programmer
Mar 18, 2002
68
GB
Hello!
Here's the problem: I want to send a javascript variable via a html form by using a hidden value, but the value doesn't get sent as it should and only the default value, "TEST" gets sent.

The javascript function, "delUser" is:
Code:
function delUser()
{
var removeUserid = document.privForm.privUsers.options[document.privForm.privUsers.selectedIndex].value;

alert ("removeUserid = " + removeUserid); 

var myConfirm = confirm("Are you you want to remove " +document.privForm.privUsers.options[document.privForm.privUsers.selectedIndex].text+ " from the list of users?");
 
 if (myConfirm == true)
 {
  document.remForm.submit();
 }
 else
 {//nothing
 }
}

The html form is:
Code:
<FORM NAME=&quot;remForm&quot; ACTION=&quot;...removeUser&quot; ONSUBMIT=&quot;remForm.myRemove.value= removeUserid;&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;myRemove&quot; VALUE=&quot;TEST&quot;>
<INPUT TYPE=&quot;BUTTON&quot; VALUE=&quot;Remove User&quot; onClick=&quot;delUser();&quot;>
</FORM>

The javascript alert box displays the variable correctly, so there is some reason that the form is not including it when it is submitted. Everything else works OK, i.e. the correct location is reached on submitting.
Any ideas where I may be going wrong!?

Thank-you,
Hazel
 
why not insert remForm.myRemove.value= removeUserid; in the function itself (before the submit() command)...

Known is handfull, Unknown is worldfull
 
What a star you are!
It worked perfectly!
Thanks a million. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top