By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,261 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,261 IT Pros & Developers. It's quick & easy.

find values of text field without using a form

P: n/a
I have reason to use a text field outside of a <formtag, but I'm
having trouble checking the value of the form. The idea is to grab the
field value and append it to a redirect.

The problem is I can't get the field value. Here's the code I'm trying
to use:

in my .aspx page:
<td width="140"><input type="text" name="searchString"
id="SearchString" class="smallFont" style="width: 135px;" /></td>
<td width="25" align="right"><input type="image" name="searchButton"
id="searchButton" src="/_images/goButton.gif" onclick="submitSearch()"
/></td>

in my .js file:

function submitSearch() {
alert(document.getElementById('searchString').valu e);
}

When i click the searchButton image, I get the following javascript
error:
Error: document.getElementById("searchString") has no properties

any ideas?? I've checked multiple websites and believe this is the
right method of doing this, but well.. I get the error.

Jul 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Kevin Blount wrote:

<td width="140"><input type="text" name="searchString"
id="SearchString" class="smallFont" style="width: 135px;" /></td>
^^^^^^^^^^^^
If the id is "SearchString" then you need to pass exactly that to
alert(document.getElementById('searchString').valu e);
getElementById, but you pass in "searchString".

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 24 '06 #2

P: n/a
Thanks Martin. Tis was a case of looking at it too long. I know that
JavaScript (and C#.NET which I'm also writing in) is case sensitive...
I just didn't even spot that I had an upper S for the ID.. it's weird,
as I never start field names/IDs with upper case letters, so I guess I
didn't think of looking at this one, especially as "name" is the
correct case.

cheers :)

Kevin

Martin Honnen wrote:
Kevin Blount wrote:

<td width="140"><input type="text" name="searchString"
id="SearchString" class="smallFont" style="width: 135px;" /></td>
^^^^^^^^^^^^
If the id is "SearchString" then you need to pass exactly that to
alert(document.getElementById('searchString').valu e);

getElementById, but you pass in "searchString".

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.