Solved

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

Posted on 2012-03-23
4
342 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

830 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