Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help adding code block on my blog?

  1. Aug 10, 2016 #1
    I was wondering if you guys could help me design (code) a slick code block in my blog like the one here that the reader could scroll? I'm very new to HTML and Java but if I could get just a little help, I would work on it. I really don't have a clue how to add the following to my HTML file but I did get several HTML references. Perhaps someone could direct me to a particular HTML topic?

    Code (Text):
    ringNum = 1
    mnum = 1
    baseRoot = 0;
    wOffset = 0
    nmax = 15;
    {rmin, rmax, wstart, wend} = theInitialValues[[ringNum]];
    loopmax = 2 \[Pi] totalSheets;
    theorder = manifoldOrders[[ringNum, mnum, 2]];
    Print["Order is: ", theorder];
    rangemin = theInitialValues[[ringNum, 1]];
    rangemax = theInitialValues[[ringNum, 2]];
    rd = (rmax - rmin)/10;
    rstart = rmin + rd;
    rend = rmax - rd;
    rnorm = (rmin + rmax)/2;
    z0 = 0;
    tval = thetStart;
    wSheet = theFunctionRoots[[manifoldOrders[[ringNum, mnum, 1]]]];
    wSheet = theFunctionRoots[[11]];
    myRadialTable = {\[Psi][\[Rho]] /.
        NDSolve[{theRhoDeriv /. \[Theta] -> tval, \[Psi][
            rnorm] == (wSheet /.
             z -> rnorm Exp[I tval])}, \[Psi], {\[Rho], rnorm,
          rstart}], \[Psi][\[Rho]] /.
        NDSolve[{theRhoDeriv /. \[Theta] -> tval, \[Psi][
            rnorm] == (wSheet /.
             z -> rnorm Exp[I tval])}, \[Psi], {\[Rho], rnorm, rend}]};
    Clear[xcod, xdcod, ycod, ydcod];
    rnum = rnorm;
    xcod[t_] := rnum Cos[t];
    xdcod[t_] = \!\(
    \*SubscriptBox[\(\[PartialD]\), \({t}\)]\(xcod[t]\)\);
    ycod[t_] := rnum Sin[t];
    ydcod[t_] = \!\(
    \*SubscriptBox[\(\[PartialD]\), \({t}\)]\(ycod[t]\)\);
    tstart = tval;
    tend = tval + 2 theorder \[Pi];
    Clear[mysol, myw];
    mysol = First[
       NDSolve[{theThetaDeriv /. \[Rho] -> rnum, \[Psi][tstart] ==
          First[(myRadialTable[[2]] /. \[Rho] ->
              rnum)]}, \[Psi], {\[Theta], tstart, tend},
        MaxStepSize -> 0.001, MaxSteps -> 500000]];
    myw[t_] := Evaluate[\[Psi][t] /. mysol];
    myVarw[t_] :=
         t <= 2 theorder \[Pi]}, {myw[t - 2 theorder \[Pi]],
         t > 2 theorder \[Pi]}}];
    If[theorder > 1,
       baseSol =
        NDSolve[{f'[t] == (-rnum Sin[t] + I rnum Cos[t])/(
           theorder f[t]^(theorder - 1)) ,
          f[tstart] ==
           Exp[(2 \[Pi] I baseRoot)/theorder] Power[rnum Exp[tstart I],
             1/theorder]}, f, {t, tstart, tend}];
       theBaseM[t_] := Evaluate[f[t] /. baseSol];
      theBaseM[t_] := rnum Exp[I t];
    thealist1 = Table[
      n1 = NIntegrate[(xdcod[t] +
           I ydcod[t])/(theBaseM[t])^((j + theorder)) myw[
          wOffset + t], {t, tstart, tend}, MaxRecursion -> 20];
      If[Length[n1] == 1,
       {j, First[N[1/(2 theorder \[Pi] I) (n1)]]},
       {j, N[1/(2 theorder \[Pi] I) (n1)]}
       ], {j, -nmax, nmax}]
    Sent from Mail for Windows 10
    Last edited: Aug 10, 2016
  2. jcsd
  3. Aug 10, 2016 #2


    User Avatar
    Gold Member

    Seriously? We're supposed to figure out what that code does?

    If you are just trying to add a scrollable window to a web page, that's just some javascript.
  4. Aug 10, 2016 #3
    I am really sorry for that. Didn't mean to imply I needed help with that code. I just gave an example of a long bunch of code to make the window scroll.

    Yes, I'm trying to add a scrollable window to the web page.
  5. Aug 10, 2016 #4
    I think you need to read a quick tutorial on HTML. This can be done using one simple tag
  6. Aug 10, 2016 #5
    Oh wow, I just googled "how to add a scrollable window to web page:

    <div style="width:150px;height:150px;line-height:3em;overflow:auto;padding:5px;">
    This 'div' element contains more content than the previous one. Because there's too much text to fit into the box, the box grows scrollbars.
    I really didn't even know what to google for. I'll work on these. Thanks guys.
  7. Aug 10, 2016 #6


    User Avatar
    Gold Member

    If you want just a scrollable table, then Greg's code works great. If you want a non-scrolling header, it gets more complicated and is what I was talking about when I said it was JavaScript. Here's an example. Just view the source code of this page:

  8. Aug 10, 2016 #7
    Can I please ask how do I view the source code for that page? I know if I select from my browser "more tools/developer tools" I get some sort of html viewer but that doesn't look like all of that code. Is that how I view all of the code for bigFourVersion.html?

    I do like keeping the headers visible in some applications.
  9. Aug 10, 2016 #8
    Right click and then select view source
  10. Aug 10, 2016 #9
    Thanks. Didn't notice that option and it's nicely formatted too. Although the <iframe> block looks nice, the <div> block is is not a bad start for me although I do have to manually add the <br/> commands:
    <div style="width:550px;height:150px;line-height:1.5em;
    overflow:auto;padding:5px;font:12pt;font-family: monospace; color: black;background: bisque">

    too much text to fit into the box, the box grows scrollbars. <br/>
    ringNum = 1<br/>
    mnum = 1<br/>
    baseRoot = 0;<br/>
    wOffset = 0<br/>
    nmax = 15;<br/>
    {rmin, rmax, wstart, wend} = theInitialValues[[ringNum]];<br/>
    loopmax = 2 \[Pi] totalSheets;<br/>
    Clear[mysol, myw];<br/>
    mysol = First[<br/>
       NDSolve[{theThetaDeriv /. \[Rho] -> rnum, \[Psi][tstart] == <br/>
          First[(myRadialTable[[2]] /. \[Rho] -> <br/>
              rnum)]}, \[Psi], {\[Theta], tstart, tend},<br/>
        MaxStepSize -> 0.001, MaxSteps -> 500000]];<br/>
    myw[t_] := Evaluate[\[Psi][t] /. mysol];<br/>
    myVarw[t_] := <br/>
         t <= 2 theorder \[Pi]}, {myw[t - 2 theorder \[Pi]],<br/>
         t > 2 theorder \[Pi]}}];<br/>
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted

Similar Discussions: Help adding code block on my blog?
  1. Code Blocks (Replies: 2)