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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update textfield value when clicking submit button 1

Status
Not open for further replies.

optjco

IS-IT--Management
Apr 13, 2004
185
GB
Is it possible to change the value of a textfield when a submit button is clicked to update a table

Regards

Olly
 
Code:
<input type="submit" value="Update table!" onclick="this.form.elements['txtfld'].value = 'New value!';">

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Chessbot,
I think I may have mislead you slightly.

I have an update form where 2 textareas are populated(txtCause & txtAction) also I have a read only field(txtStatus) that is populated earlier from an Insert form with the following text("Outstanding").

What I need is that when the two fields are populated and before the update is submitted then the field ("Outstanding") is changed to ("Pending")

Regards

Olly
 
Guys,
I managed to get some code working by editing a script I found however I am sure there is someone out there that could perhaps help me streamline it

Code:
<script Language = "javascript" >
function checkBoxes(){
  boxArr = new Array("txtCause")
  dataFound = "Outstanding"
  for (x=0; x<boxArr.length; x++){
    boxVal = eval ("document.frmPending." + boxArr[x] + ".value")
    if (boxVal != ""){
      dataFound = "Pending"
    }
  }
  document.frmPending.txtStatus.value = dataFound
}

</script>

I am then calling the function with this

Code:
onSubmit="checkBoxes()"



Regards

Olly
 
If that works, consider changing
Code:
    boxVal = eval ("document.frmPending." + boxArr[x] + ".value")
to
Code:
    boxVal = document.frmPending.elements[boxArr[x]].value;
to decrease processing time.

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top