Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Javascript querystring

Posted on 2013-06-24
6
Medium Priority
?
328 Views
Last Modified: 2013-06-24
Hi Experts,

I have the code below, that essentially should take the contents of one textbox, reload the page and place the querystring back into the textbox. The only problem I have is it places the text in but it disappears straight away. I tried the second line with a different textbox but got the same issues

function redirec() {
            location.href = "index.html?" + document.getElementById('Text1').value;
            document.getElementById('Text1').value = window.location.search.slice(1);
        }

Open in new window

0
Comment
Question by:takwirirar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 39271543
the population of the textbox has to be done in the new page onload. You have a new page loaded that has no clue what instructions were executed from the previous page. the only reason you see it briefly id that javascript does not way for commands to finish executing before it does the next instruction.



Cd&
0
 
LVL 1

Author Comment

by:takwirirar
ID: 39271624
I have this in the second page but the text box is not prepopulating

 <script type="text/javascript">

        function onll() {

           document.getElementById('Text1').value = window.location.search.slice(1);
        }


    </script>
</head>
<body onload="onll">
    <input id="Text1" type="text" />
</body>

Open in new window

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 39271672
From the tiny snippets, it looks like it should work.  The fact that it does not means there is something in the page or on the server side screwing it up.  Post a link and maybe we can get a better idea of why it is not working.

Cd&
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:takwirirar
ID: 39271688
Ok thanks the link is http://apaneapa.com/index1.html
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 2000 total points
ID: 39271744
<body onload="onll">

Should be:

<body onload="onll();">

It is only when you fire from inside the script that you leave of the parenthesis.

Cd&
0
 
LVL 1

Author Closing Comment

by:takwirirar
ID: 39271770
Fantastic and quick responses.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question