mfarrell Posted February 2, 2015 Share Posted February 2, 2015 I am considering trying to do something like this.... Data on one page (form) to be sent or read by another page as Java Script..so that I can separate the input form from the results page for clarity. Calculations page >>>> Feeds values to a graphical results page....at this moment I want to use a script IF possible as this is a local development with no 'server' side processes. Link to comment Share on other sites More sharing options...
Ingolme Posted February 2, 2015 Share Posted February 2, 2015 The only way to pass data from one page to another is through the query string. Construct a query string with the format ?var1=value&var2=value and then use the location object to load a URL with that query string appended to it. Link to comment Share on other sites More sharing options...
Ingolme Posted February 2, 2015 Share Posted February 2, 2015 If your application is purely Javascript, there's no reason why you would need more than one page to do everything. Link to comment Share on other sites More sharing options...
davej Posted February 2, 2015 Share Posted February 2, 2015 "Clarity" is when you only do things that make sense. You can have an input div and an output div on the same page and can hide one or the other using display:none. <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>Hide Divs</title><style>div{border: 1px solid #aaa;border-radius:5px;margin:5px;background-color: #eee;}p, input{margin: 5px 10px}[type=button]{background-color: #eee;}</style><script>window.onload = function() { document.getElementById('outdiv').style.display = 'none'; document.getElementById('btn1').onclick = swapf; document.getElementById('btn2').onclick = swapf;}function swapf() { if (this.id=='btn2'){ document.getElementById('indiv').style.display = 'none'; document.getElementById('outdiv').style.display = 'block'; } else if (this.id=='btn1'){ document.getElementById('outdiv').style.display = 'none'; document.getElementById('indiv').style.display = 'block'; } else { alert('unknown btn'); }}</script></head><body><input type="button" id="btn1" value="See Inputs"/><input type="button" id="btn2" value="See Outputs"/><br/><div id="indiv"><h2>Input stuff</h2><p>Input stuff1</p><input type="text" placeholder="input1"/><p>Input stuff2</p><input type="text" placeholder="input2"/><p>Input stuff3</p><input type="text" placeholder="input3"/></div><div id="outdiv"><h2>Output stuff</h2><p>Output stuff1</p><p>Output stuff2</p><p>Output stuff3</p></div></body></html> Link to comment Share on other sites More sharing options...
mfarrell Posted February 2, 2015 Author Share Posted February 2, 2015 A couple of good things to consider....Let me see how well this fits... One of the differences between knowledge and wisdom. One might know how to do something. Another might be wise enough to know not to. Link to comment Share on other sites More sharing options...
mfarrell Posted February 2, 2015 Author Share Posted February 2, 2015 Can I give the input(s) an ID? <h2>Input stuff</h2><p>Input stuff1</p><input id= "Input1" input type="text" placeholder="input1"/></div><div id="outdiv"><h2>Output stuff</h2><p>$(#Input1)</p> Would this be how I get that information to show up in the output? Also why are there two of each button? One that works and one that doesn't? Link to comment Share on other sites More sharing options...
davej Posted February 3, 2015 Share Posted February 3, 2015 I started with one button and then thought two buttons might be less confusing for a user. You can of course add any other id's that you need. Link to comment Share on other sites More sharing options...
mfarrell Posted February 3, 2015 Author Share Posted February 3, 2015 (edited) I started with one button and then thought two buttons might be less confusing for a user. You can of course add any other id's that you need. Let me clarify my question about the buttons, there are two of each...only one set doesn't function at all. Was that intentional, or an accident of formatting? I ask because I can't seem to get rid of the extra buttons? Edited February 3, 2015 by mfarrell Link to comment Share on other sites More sharing options...
davej Posted February 3, 2015 Share Posted February 3, 2015 Where in my code above do you find more than two buttons? Link to comment Share on other sites More sharing options...
mfarrell Posted February 3, 2015 Author Share Posted February 3, 2015 Where in my code above do you find more than two buttons? That is the source of my question I don't 'see' TWO sets of buttons in your code, yet it displays two sets of buttons in browser. See the attached image above.... Link to comment Share on other sites More sharing options...
davej Posted February 3, 2015 Share Posted February 3, 2015 Perhaps your cut and paste created a duplication in your file? Delete everything in the file and try pasting in a fresh copy. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now