Solved

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

Posted on 2012-03-23
4
332 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
4 Comments
 
LVL 15

Assisted Solution

by:pateljitu
pateljitu earned 250 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 28

Accepted Solution

by:
sammySeltzer earned 250 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now