×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to reset the value of a hidden HTML element

How to reset the value of a hidden HTML element

How to reset the value of a hidden HTML element

(OP)
I'm working with code developed by another unknown person that gathers data with an HTML form embedded within a VBScript, validates the data, then closes the form once all data is valid. Here's the form part of the HTML code:

   ' Create IE object and set its appearance
    Set objIESignon = CreateObject( "InternetExplorer.Application" )

    objIESignon.Navigate "about:blank"

    Wait_SURF_Window

    objIESignon.Document.Title = "SURF Data"
    objIESignon.ToolBar = False
    objIESignon.Resizable = False
    objIESignon.StatusBar = False
    objIESignon.Left = 100
    objIESignon.Top = 100
    objIESignon.Width = 500
    objIESignon.Height = 325

    ' Insert the HTML code to prompt for the dialog
    objIESignon.Document.Body.InnerHTML = "<DIV align='center'>" & _
    "<TABLE width='100%' id='table1' border=1 style='background-color: rgb(155, 205, 155)'>" & _
    "<TR>" & _
    "<TD colspan=2>Number of Updates:<br>" & _
    "<INPUT name='txtNoU' title='Numeric 1 or 2 digits only' TYPE='text' SIZE= '15' ID='txtNoU'></TD>" & _
    "</TR>" & _
    "<TR>" & _
    "<TD colspan=2>" & _
    "Work Reassigned:</span><br>" & _
    "<select name='ddlReassign' ID='ddlReassign'>" & _
    "<option selected='selected' value=''>Select One</option>" & _
    "<option value='Yes'>Yes</option>" & _
    "<option value='No'>No</option>" & _
    "</select></TD>" & _
    "</TR>" & _
    "<TR>" & _
    "<TD colspan=2>Consulting SME Utilized:<br>" & _
    "<select name='ddlSME' ID='ddlSME'>" & _
    "<option selected='selected' value=''>Select One</option>" & _
    "<option value='No'>No</option>" & _
    "<option value='Yes1'>Yes-Resolution found documented in SOP</option>" & _
    "<option value='Yes2'>Yes-Resolution needs to be documented in SOP</option>" & _
    "</select></TD>" & _
    "</TR>" & _
    "<TR>" & _
    "<TD colspan=2>Comments:<br>" & _
    "<textarea maxlength=255 rows=2 cols=20 name ='txtComments' ID='txtComments' Title='Free flowing 255 characters'></textarea></TD>" & _
    "</TR>" & _
    "<TR>" & _
    "<TD colspan=2><br>" & _
    "<INPUT TYPE='submit' VALUE='Submit' OnClick='VBScript:Submit.Value=1'>&nbsp;&nbsp;&nbsp;" & _
    "<INPUT TYPE='button' VALUE='Reset' OnClick='VBScript:Reset.Value=1'>&nbsp;&nbsp;&nbsp;" & _
    "<INPUT TYPE='hidden' ID='Submit' NAME='Submit' VALUE='0'>" & _
    "<INPUT TYPE='hidden' ID='Reset' NAME='Reset' VALUE='0'><br><br>" & _
    "</TD>" & _
    "</TR>" & _
    "</TABLE>" & _
    "</DIV>"

    ' Make the window visible
    objIESignon.Visible = True

    ' Bring dialog window to top of window z order (in case it is under another window)
    WShell.AppActivate "SURF Data" 

The form stays alive due to a Do While...Loop that terminates when the hidden Reset value becomes 1...meaning the reset button has been pressed, otherwise, the form waits until the user has submitted the required data by pressing the Submit button.

My issue is in the validation. I have this to decide whether or not all data is valid:

      ' Validate entries before dialog can be dismissed
      if NumIsValid(objIESignon.Document.GetElementById("txtNoU").Value) Then
         if ReassignValid(objIESignon.Document.GetElementById("ddlReassign").Value) Then
            if ConsultSMEValid(objIESignon.Document.GetElementById("ddlSME").Value) Then
               exit do
            end if
         end if
      end if 
Obviously, each if references a function that checks to see if the data is valid. If all three check out, we exit the Do Loop and the form should go away. That does work. What doesn't is if I test either of the three, the respective function tells them they need to enter a valid response, then waits for them to do so. Let's say I leave the number of updates blank. Here's the function that does the validation:

Function NumIsValid(NumOfUpdates)

    Dim Updates

    ' So that we can modify it without modifying the incoming parameter
    Updates = NumOfUpdates

    if  Len(Updates) > 2 Or Len(Updates) < 1 then
        Msgbox "You must enter a number that is 1 or 2 digits long." & chr(13) & chr(13) & "For example: 1  or  34" & chr(13) & chr(13) + "Please enter a valid number of updates.",,"Invalid Number of Updates"
        NumIsValid = False
        Exit Function
    end if

    NumIsValid = True

End Function 

If "NumIsValid" is False, this next line should set the Submit button hidden element back to 0. All it does is stop the script. Any consecutive lines never get processed.

objIESignon.Document.GetElementById("Submit").Value = 0 ' reset back to not clicked 

Any idea on why it's not working? Or can you guide me to a better solution that will actually work?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close