?
Solved

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

Posted on 2012-03-23
4
Medium Priority
?
348 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

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
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

800 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