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

x
?
Solved

Calling url with querystring and text in querystring to come from textfield

Posted on 2012-03-23
4
Medium Priority
?
349 Views
Last Modified: 2012-08-14
Hi Experts,

In my html form,

I want whatever text is entered in text field txtSearch

<input name="txtSearch"

and on click of image button

I want when user click on image button,

<input name="Submit2" id="txtbutton" type="image"

another url to be called with query string and query string should have

text from text field "txtSearch"

window.location.href=/Search/dosearchdin2.aspx?qt=window.document.getElementById('txtSearch').value

but my problem is, when user is clicking image button, then form submit is called and url is re-directed to different file
/Search/dosearch.asp

help me to re-direct to
window.location.href=/Search/dosearchdin2.aspx?qt=window.document.getElementById('txtSearch').value

My code is attached

Please guide

Regards
codeSnippet.txt
0
Comment
Question by:tia_kamakshi
[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
4 Comments
 
LVL 15

Assisted Solution

by:pateljitu
pateljitu earned 1000 total points
ID: 37757376
If you do not want to use <FORM> submit, please change <Input type="image" /> tag to <img src="" />

Change:
<input name="Submit2" id="txtbutton" type="image" value="Search" title="Search" src="/Images/arrow_search_blue_tcm79-155398.gif" alt="Search" onclick="changeVal();" class="headerSearchSubmit" border="0" style = "cursor:hand;border:none"/>
to:
<img src="/Images/arrow_search_blue_tcm79-155398.gif" alt="Search" onclick="changeVal();" class="headerSearchSubmit" border="0" style = "cursor:pointer;border:none"/>
0
 
LVL 29

Accepted Solution

by:
sammySeltzer earned 1000 total points
ID: 37757433
I don't see how that is happening with the code you just showed.

Try:

<input name="Submit2" id="txtbutton" type="image" src="images/bg_confirm.gif" onclick="location='/Search/dosearchdin2.aspx?qt=request("txtSearch")'">

Open in new window

0
 
LVL 7

Expert Comment

by:Lalit Chandra
ID: 37757445
You can simple use jquery to  resolve this issue.
Do the following
1. Insert the Jquery reference in Head section of your page.
2. Write the code
   $(function() {
    $("#ImageButton").click(function() {

   window.location.href="/Search/dosearchdin2.aspx?qt="  + window.document.getElementById('txtSearch').value
          return false;
     });
});

HOPE this will resolve your issue.
0
 

Author Comment

by:tia_kamakshi
ID: 37759936
Hi Experts,

Thanks for your replies

I tried


<img src="/Images/arrow_search_blue_tcm79-155398.gif" alt="Search" onclick="changeVal();" class="headerSearchSubmit" border="0" style = "cursor:pointer;border:none"/>

and

<input name="Submit2" id="txtbutton" type="image" src="images/bg_confirm.gif" onclick="location='/Search/dosearchdin2.aspx?qt=request("txtSearch")'">

both has not worked, not sure why onclick is not firing. I have added alert also on my javacript, that alert is also not coming.

Don't know what is the reason

Yes, I am not good at jquery

and jquery does not work match my current javascript function

my current function as attached before is
function changeVal()
            {
                                if (window.document.getElementById('txtSearch').value != '' && window.document.getElementById('txtSearch').value != "null")
            {
                                    window.document.getElementById('QU').value=window.document.getElementById('txtSearch').value
                                    window.location.href=/Search/dosearchdin2.aspx?qt=window.document.getElementById('txtSearch').value
            }
            else
            {
                  alert("Please enter search parameters ..!!!");
            }            }
       


Please suggest


Regards,
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

609 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