Lieutenant Dan
Lieutenant Dan

Reputation: 8274

grab variable from page and store in new variable

I am trying to grab dynamic data as below. Seen from file.

<tr>
    <td><%= locationNumber %></td>
    <td><%= locationDba %></td>
    <td><%= address1 %><%= address2 %><br><%= city %>, <%= state %> <%= zipcode %></td>
    <td><%= storePhone%></td>
</tr>

I would like to write javascript in a global js file that grabs 'locationDba' variable or dynamic content and stores in a new variable that I create so I can use it across an application easier with a new variable; EG. newlocationDBA. But with the same data as found working in original file 'locationDba'.

    <td><%= **new**locationDba %></td>

Alright! Update; below is my most recent attempt with no results.


Mark-Up. CALL.

   <option><%= myGlobalDba %></option>

JS file.

var myGlobalDba = document.getElementById('search').innerHTML; 

Mark-Up. GRAB.

<td id="search"><%= locationDba %></td>

So, shouldnt my mark-up call output the exact same as original <%= locationDba %> ? Am I missing something within the javaScript?

Upvotes: 0

Views: 60

Answers (1)

dthree
dthree

Reputation: 20730

<td id='cows'><%= **new**locationDba %></td>

and

var myGlobalDba = document.getElementById('cows').innerHTML;

If this doesn't answer your question, then you are missing something about your question. For example, what is <%= **new**locationDba %>? Looks like a server-side template.

Upvotes: 1

Related Questions