none
New User Question RRS feed

  • Question

  • I have a question related to HTML and Javascript.  Let me begin by stating that I am new to both of these topics.  I am an accountant and am in no way attempting to begin a second career as a developer, but I do need to obtain a basic level understanding of how these two worlds can be used to build applications.  I have been given an audit program application that uses HTML and I assume Javascript to accomplish a feat that I would like to replicate.  First let me explain what the application does.

    As the user reads the audit program, there are buttons the user can click on which bring up a list of related items.  For example, the items may be internal control statements consisting of 2 or 3 sentences.  There is a checkbox next to each statement for the user to check.  Using my basic knowledge of HTML, I have been able to replicate this part of the process.  The problem comes here….what to do with the checked item?  The way the application is supposed to work is that it takes the checked item and inserts it back into the document from which you were originally working.  I assume this is where the JAvascript comes into play?  Can you use HTML to pass a value from one document to another non-HTML document, or do you have to rely on scripting?  Not sure if I explained that very well, but again, I am in new territory here.  Any suggestions or commentary you can give would be much appreciated.
    Monday, October 3, 2016 6:14 PM

Answers

  • HTML is a layout language. Not a programming language.

    <p>This is a paragraph</p>

    <h1>This is the biggest heading</h1>

    <a href=http://ww.microsoft.com>This is a hyperlink to Microsoft</a>

    Web pages can use JScript as a scripting language, and on intranets you can use VBScript. Most webpages are both layout and script.

    Here is a combined document that searches the internet. You can see how both vbscript and html are mixed together. Create Search.hta and paste this in to it. HTA are web pages that normal web security doesn't apply.

    <HTML>
    <HEAD><TITLE>Search</TITLE>
      <HTA:APPLICATION ID="oMyApp"
        APPLICATIONNAME="Search"
        BORDER="normal"
        BORDERSTYLE="sunken"
        CONTEXTMENU="yes"
        CAPTION="yes"
        ICON="C:\windows\system32\shell32,-5"
        SCROLL="no"
        SHOWINTASKBAR="yes"
        SINGLEINSTANCE="yes"
        SYSMENU="yes"
        WINDOWSTATE="normal"
      />

    <style>
    BODY  {font-size :100%;font-family: Arial, Helvetica, sans-serif;color: black;
      background:URL(images/watermark.gif);background-color: white;
      margin-top:20pt; margin-left:40pt; margin-right:10pt ; text-align:Justify}
    P  {margin-left:0pt;margin-right:0pt}
    </style>

    <SCRIPT LANGUAGE="VBScript">
    Dim Searchterm

    Sub Search
    ' On Error Resume Next
     Set WshShell = CreateObject("WScript.Shell")
     If tb2(5).Checked=True then WshShell.Run "https://www.google.com/maps/place/" & Replace(tb1.value, " ", "+")
     If tb2(4).Checked=True then WshShell.Run "https://www.google.com/search?q=" & Replace(tb1.value, " ", "+") & "&cr=countryAU"
     If tb2(3).Checked=True then WshShell.Run "https://www.google.com/search?q=site:msdn.com+" & Replace(tb1.value, " ", "+")
     If tb2(2).Checked=True then WshShell.Run "https://www.google.com/search?q=nethack+" & Replace(tb1.value, " ", "+")
     If tb2(1).Checked=True then WshShell.Run "https://en.wikipedia.org/wiki/" & tb1.value
     If tb2(0).Checked=True then WshShell.Run "https://www.google.com/search?q=" & Replace(tb1.value, " ", "+")
     WshShell.RegWrite "HKCU\Software\StackOverflow\VBS\Searchterm", tb1.value & vbtab & WshShell.RegRead("HKCU\Software\StackOverflow\VBS\Searchterm")
     If tb3.checked=true then window.close
    End Sub

    Sub Init
     Count = 0
     window.resizeTo 550, 400
    ' On Error Resume Next
     Set WshShell = CreateObject("WScript.Shell")
     HistoryArr = Split(WshShell.RegRead("HKCU\Software\StackOverflow\VBS\Searchterm"), Chr(9))
     tb1.value = HistoryArr(0)
     For each t in HistoryArr
      Count=Count + 1
      Set Hist = document.createElement("OPTION")
      Hist.Text=t
      Hist.Value=Count
      HistoryList.Add(Hist)
      Count=Count + 1
      If Count > 50 then exit For
     next
     tb1.select
    ' tb1.focus
    End Sub

    Sub Paste
     tb1.value=document.parentwindow.clipboardData.GetData("TEXT")
     tb1.select
    End Sub

    Sub LBTransfer
     x = CLng(HistoryList.Options.selectedindex)
     tb1.value = HistoryList.Options(x).text
     tb1.select
    End Sub

    Sub LBTransferK
     x = CLng(HistoryList.Options.selectedindex)
     tb1.value = HistoryList.Options(x).text
     HistoryList.focus
    End Sub
    </script>
    </head>

    <body Onload=Init>
    <p><b>Enter <u>s</u>earch term</b></p>
    <p><INPUT Name=tb1 TYPE=Text size=60 AccessKey=s> <INPUT Type=Button onclick=paste Value=Paste AccessKey=p></p>
    <p><b><u>H</u>istory</b></p>
    <p><SELECT NAME="HistoryList" SIZE="4" Onclick=LBTransfer OnKeyPress=LBTransferK AccessKey=h>
    </SELECT></p>
    <p><b>Search <u>w</u>here</b></p>
    <p><INPUT Name=tb2 TYPE=RADIO CHECKED AccessKey=w> Google <INPUT Name=tb2 TYPE=RADIO> Wikipedia <INPUT Name=tb2 TYPE=RADIO> Nethack <INPUT Name=tb2 TYPE=RADIO> MSDN <INPUT Name=tb2 TYPE=RADIO> Australia <INPUT Name=tb2 TYPE=RADIO> Maps </p>
    <p><INPUT NAME="Search" TYPE="SUBMIT" VALUE="Search" OnClick=Search> <INPUT Name=tb3 TYPE=CHECKBOX CHECKED AccessKey=c> <u>C</u>lose on search</p>


    </body>
    </html>


    David Candy

    • Marked as answer by jdmcleod Wednesday, October 12, 2016 10:04 PM
    Monday, October 10, 2016 11:17 AM