Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

863 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

28 Experts available now in Live!

Get 1:1 Help Now