When you submit the form, you change the session (in your case you reload the page). When you change the session, you lose all the JavaScript changes, because JavaScript is a client-side language.
Either you are really confused or I am really confused and missing something because from what I see, all you are trying to do is use the text in a textbox in the 2nd form to be the value of a select list in the 1st form.
To do that, I don't see why you need a submit button on the 1st form. It could be just a plain button or clickable object with the appropriate onclick function.
You are also submitting the page to itself and I can't see why you need to do that in order to transfer the data from the second form to the first.
tirna - exactly right, although the eventual aim is for the 'output' to show a concatenation of several form entries.
I know it's not complicated, but I can't seem to do it - any help?
Do you need to submit the form? As in:
Do you need to send the form-data to your server for storing, or do you simply wish to keep the data stored in the browser for usage there and then?
If you need to store the data, you need to submit the form to the server (with or without ajax), and then pick things up from there. Then you might need to do some coding on your backend of course.
If you have no need for storage, but simply wish to perform operations on input, you can skip the submit and simple store the values of your input-fields in an array, clear the form, and continue to let the user add results to the array.
Then you can make a button on your page that will perform the operations on all the data in the array, whatever they look like.
As of right now though, it's a little difficult to understand what you REALLY want.
- Spinner
Producer, Developer, Gamer, Father and Husband.
Hi.
Let me say I am mightily amused that North East Lincolnshire's favourite town has had the filtering treatment - and to think I nearly included P***stone!
Okay, so what I am aiming for is to dynamically create a URL. This would resemble an HTML form submitted with GET, except that I need it to display on screen so that others could copy and paste it and include it on emails etc.
As an example, the output could be:
However, my question remains the same:
Do you need to store the submitted data on the server?
If so, it is probably caught by some server script that can handle the data? And if so, you have all the data in the post right there, to put into the form on the result-page or anywhere you might want it...
If you don't need anything to go to the server, you don't have to submit it to the server in the first place....Just pick up the data from the form when a normal button is pressed and perform your operations then.
- Spinner
Producer, Developer, Gamer, Father and Husband.
1: Create the function to move the data between 2 fields
function moveValueBetween(from,to){
if (document.getElementById(from)){
if (document.getElementById(to)){
document.getElementById(to).value=document.getElementById(from).value;
}
}
}
2: Replace your submit-button with
<input type="button" value="Click me" onclick="moveValueBetween('input_id_1','input_id_2');"/>
A very quick fix, but I gotta go.
- Spinner
Producer, Developer, Gamer, Father and Husband.
<body> <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible!
try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.output.output1.value = ajaxRequest.responseText; } } ajaxRequest.open("GET", "text.php", true); ajaxRequest.send(null); }
//--> </script> <div id="container"> <div id="title"> <h1>Marketing Session Search</h1> <span id="subtitle">Create a link for the nearest sessions in a specified area. </span> <br /> Would you like to include this in an email? Click here to access the <span style="font-weight:bold;">mailer</span>. </div> <div name="form1"> Enter the details onto the form. <form method="get" name="formdata" id="formdata" onChange="ajaxFunction();"> <table style="background-color:#FC6; color:#900"> <tr> <td>Area</td> <td> <select name="area" id="area" size="5" > <option value="NS" selected>North Sheffield</option> <option value="BA">Barnsley</option> <option value="NR">North Rotherham</option> <option value="DO">Doncaster</option> <option value="SC">S****horpe</option> <option value="GC">Grimsby/Cleethorpes</option> <option value="LN">Lincoln</option> <option value="SK">Skegness</option> <option value="SL">Boston/Spalding</option> <option value="OT">Other</option> </select> </td> </tr> <tr> <td>Start Date:</td> <td><input type="text" name="date" id="date"/> <script type="text/javascript"> calendar.set("date"); </script> </td> <tr> <tr> <td>Finish Date:</td> <td><input type="text" name="fdate" id="fdate"/> <script type="text/javascript"> onfocus(fdate)) { document.write("date") } </script> </td> </tr> <tr> <td>Include Weekends?</td> <td><input name="wknd" type="radio" value="MTWHFSU" checked />Yes <input name="wknd" type="radio" value="MTWHF" />No <br /> <input name="wknd" type="radio" value="SU" />Weekends only </td> </table>
Bookmarks