Jump to content

Passing User Input data to another page?


mfarrell

Recommended Posts

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

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

"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

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

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?

post-180294-0-34088000-1422976174_thumb.png

Edited by mfarrell
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...