i am fully aware about the fact that there are dozens of questions that go along this but i felt that my scenario was a little different(Upto you to decide), Im trying to transfer a form data from 1 HTML(test.html) to another HTML(tut1.html)
Basically what i am trying to do is extract the data and show in another modal.The issue i came across is i managed to do the same thing in a test run , but for some reason when i added it to my main one it didnt really work. I am sure i have missed something small but i can not pin it. Any help to fix this would be of great help.(One thing you can take note is that in the test run i used a button to submit but here instead i am using a href.not sure if thats what is causing this. Also one thing i noted was that the page is getting redirected to the second page due to the link of href and not because of the form action)
HTML 1 contain the form.Where the user enters his input.
<html>
<head>
</head>
<body>
<div class="feedback-background">
<div class="feedback-content">
<div class="close">+</div>
<img src="E:\IIT\Lectures\WEB\coursework1\Images\feedbackimg1.jpg" alt="Givefeedback" style="width:100px;height:100px;">
<form name="FeedbackForm" method="get">
Name:
<input id="Name" name="N" type="text" placeholder="Name">
E-Mail:
<input id="E-mail" name="E-mail" type="email" placeholder="E-mail">
What do you think about us?<br>
<textarea id="comment" rows="6" cols="33" name="C"></textarea>
<br>
How would you rate us ?
<br>
<label><input type ="radio" name="rating" id="rating" value="Excellent" checked>Excellent</label>
<label><input type ="radio" name="rating" id="rating" value="Very Good">Very Good</label>
<label><input type ="radio" name="rating" id="rating" value="Average">Average</label>
<label><input type ="radio" name="rating" id="rating" value="Poor">Poor</label>
<label><input type ="radio" name="rating"id="rating" value="Extreamly Poor">Extremely Poor</label>
<br>
<a href="tut1.html" onClick="testJS()" id="submit" type="submit">SUBMIT</a>
</form>
</div>
</div>
<script>
function testJS() {
var b = document.getElementById('Name').value,
document.getElementById('comment').value,
url = 'http://E:\IIT\Homework\web1t/tut1.html?Name=' + encodeURIComponent(b);
document.location.href = url;
}
</script>
</body>
HTML 2 (tut1.html) contains a modal i have created(not including the css for ur ease)
<body>
<div class="popup">
<div class="popuptext" id="myPopup"><p>Thank you <span id="username"></span> ,<br>Your feedback has been recorded.<br>
<br>You commented that"<span id="usercomment"></span>" <br><br>and rated our website "<span id="userrating"></span>".
<br><br>Thank you
for taking your time to do so.<br><br>You will now be re-directed automatically</p>
</div>
</div>
<script>
window.onload = function () {
var url = document.location.href,
params = url.split('?')[1].split('&'),
data = {}, tmp;
for (var i = 0, l = params.length; i < l; i++) {
tmp = params[i].split('=');
data[tmp[0]] = tmp[1];
}
document.getElementById('username').innerHTML = data.N;
document.getElementById('usercomment').innerHTML = data.C;
}
</script>
</body>
PS: i used the exact 2 codes in order to fill another form but it was extremely simple and it worked perfectly not sure why it doesnt work here . any help in any sort would be of great help