Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change a form's input text value using JavaScript 1

Status
Not open for further replies.

AdeleMB

Technical User
Mar 31, 2008
10
GB
Hi,
I need some help to override the input value for a search box using only JavaScript.
I originally wanted to do this with CSS but a kind techie in the CSS forum here told me that it wasn't really possible while remaining cross-browser compatible.

I don't have access to the form's HTML as it is managed by a library management system but I can attach separate Javascript documents.

This is the form's HTML (which i cannot change):

Code:
<form method="get" action="items" id="searchform">
<div class="formElement">
<label class="hidden" for="s" id="jslabel">Search the library catalogue</label>
<input type="text" value="Search the library catalogue" maxlength="1000" name="query" onblur="if (this.value == '') {this.value = document.getElementById('jslabel').innerHTML;}" onfocus="if (this.value == document.getElementById('jslabel').innerHTML) {this.value = '';}" id="s"><input type="submit" value="Search" id="searchsubmit"><a title="Advanced Search" id="advanced-search-link" href="advancedsearch.php?query=Search+the+library+catalogue">More search options</a>
</div>
</form>

Is there any way to change all instances of "Search the library catalogue" to "Enter a keyword, title, author or ISBN" using JavaScript?

Thanks so much for any help!!
Adele
 
Hi

Make sure to run this after the [tt]form[/tt] was generated :
JavaScript:
document[teal].[/teal][COLOR=darkgoldenrod]getElementById[/color][teal]([/teal][green][i]'jslabel'[/i][/green][teal]).[/teal]innerHTML[teal]=[/teal]document[teal].[/teal][COLOR=darkgoldenrod]getElementById[/color][teal]([/teal][green][i]'s'[/i][/green][teal]).[/teal]value[teal]=[/teal][green][i]'Enter a keyword, title, author or ISBN'[/i][/green]

Feherke.
 
OMG you are excellent!!
Thanks so much, you've saved me soooo much time, it works brilliantly :)

Thank you,
Adele
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top