|
Sorry about the useless subject line. Say I have two buttons. Is there anyway I can use javascript, to change text displayed on the screen, depending on which button I use? If so, please let me know what it is.
|
|
|
|
|
Use a span or something, and set the innerHTML:
<span id="Thing">Text</span>
<script>
function SetText(id, text)
{
document.all[id].innerHTML = text
}
</script>
<input type=button onclick="SetText('Thing', 'Hello World');>
Untested, but is more or less what you want to get started.
--
Ian Darling
If I was any more loopy, I'd be infinite.
|
|
|
|
|
But don't use an IE only DOM 0 thingy (hint: document.all ) if it's possible to stay compatible with most (actually all) browsers by using document.getElementById(id).innerHTML = text; .
|
|
|
|
|
Good point about standards ...
But innerHTML is not actually a W3C standard ... even though it is widely supported among most browsers, weird[^].
Wally Atkins Newport News, VA, USA
|
|
|
|
|
I have several select boxes on a form. what i want is, to make open a new window when the user chooses the same option from any one of the select boxes. so for example, select1 has 4 options, select2 has 4 options etc. The 4th option is "other". If user selects "other" in any drop down list then it will open a window. what i cant work out is, how to reference all the selectboxs with one function rather than several smaller functions. This is as far as i got.
Help is most appreciated....
function other() {
var selIndex = document.formName.selectName.selectedIndex;
var optText = document.formName.selectName.options[selIndex].text;
if(optText=="Other"){
window.open('form.htm','','top=20,width=200, height=200');
}
else {
return false;
}
}
thanks in anticipation
|
|
|
|
|
Try something like:
function other(cbx)
{
if (!cbx || "undefined" == typeof(cbx.options)) return false;
var selIndex = cbx.selectedIndex;
var optText = cbx.options[selIndex].value;
if ("other" == optText)
{
window.open("form.htm", "top=20,width=200,height=200");
return true;
}
else
{
return false;
}
}
...
<select size="1" name="SelectList1" onchange="other(this);">
<option>(Select One)</option>
<option value="other">Other...</option>
</select>
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
thank you for the help.
can you explain line 1 of function, newbie to all this.
thanks again
skizzly
|
|
|
|
|
Line 1 simply says that if you don't pass in a value, or the object you pass in doesn't have a property called options , the function will return immediately.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
thanks for the help, u sure know ur stuff.
thanks for help
skizzly
|
|
|
|
|
added function to the page, but unfortunately it does nothing! any ideas...
there are several groups of select boxs in the form. is it that i have to refer to the ones i want directly, for the function to work???
|
|
|
|
|
Did you update your select boxes to pass this as the argument to the function?
The following page works perfectly in Internet Explorer and Mozilla Firebird:
<html>
<head>
<title>Testing</title>
<script language="javascript" type="text/javascript">
<!--
function other(cbx)
{
if (!cbx || "undefined" == typeof(cbx.options)) return false;
var selIndex = cbx.selectedIndex;
var optText = cbx.options[selIndex].value;
if ("other" == optText)
{
window.open("form.htm", "", "top=20,width=200,height=200");
return true;
}
else
{
return false;
}
}
</script>
</head>
<body>
<select size="1" name="SelectList1" onchange="other(this);">
<option>(Select One)</option>
<option>Item 1</option>
<option>What?</option>
<option value="other">Other...</option>
</select>
<br />
<select size="1" name="SelectList2" onchange="other(this);">
<option>(Select One)</option>
<option>Item 2</option>
<option>Another item</option>
<option value="other">Other...</option>
</select>
</body>
</html>
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Here is the code i used for the select box, identiifying the funtion. I followed to the letter your function but it wont do anything once the option "other" is selected.
When I do the function without the rest of my form and just the select boxes, the function works fine, but when added to my form it seems not to work.... do you think it has something to do with the cbx parameter?
<select name="issues" multiple class="width" onChange="other(this);"><br />
<option class="header2">GP</option><br />
<option> </option><br />
<option value="Communication/Attitude">Communication/Attitiude</option><br />
<option value="Appointment System">Apointment System</option><br />
<option value="Unable to Access treatment">Unable to Access <br />
treatment</option><br />
<option value="Premises/environment">Premises/environment</option><br />
<option value="Failiure to visit">Failure to vist</option><br />
<option value="Practice staff">Practice staff</option><br />
<option value="`Failiure to diagnose">Failiure to SDiagnose</option><br />
<option value="Other">Other</option><br />
</select>
|
|
|
|
|
The first issue is the case of the value - the function is looking for "other", in lower case. The second issue is the fact that your list allows multiple selection - the selectedIndex will only return the first selected item.
Try changing the function to:
function other(cbx)
{
if (!cbx || "undefined" == typeof(cbx.options)) return false;
var selOther = false;
for(var i = 0; i < cbx.options.length; i++)
{
var opt = cbx.options[i];
if (opt.selected && "other" == opt.value.toLowerCase())
{
selOther = true;
break;
}
}
if (selOther)
{
window.open("form.htm", "", "top=20,width=200,height=200");
return true;
}
else
{
return false;
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
thnaxs again for the help, iteration is the key here, the clouds have become lighter! thanks for your time and effort.
Skizzly
|
|
|
|
|
Im using IE 6 with Win 2k3. I want to use the "nabla" unicode character (just like an up-side-down Delta) in my HTML page, but I notice IE doesnt display it correctly.
Check out this page: hxxp://ppewww.ph.gla.ac.uk/~flavell/unicode/unidata.html
I cannot view most of the characters in set 22 - Mathematical Operators. "nabla" is hex 2207.
I thought IE supports all Unicode....
Do I need to install some special web fonts??? If so, which?
|
|
|
|
|
Hi
is there a way to change the cursor to an image you have created yourself (gif). (workable over frames....
tx
|
|
|
|
|
Only if you are using IE6. You can apply a cursor style to an element using the URL() syntax.
EX: style="cursor:URL(http://mysite.com/res/mycursor.cur)"
However, the resource must be a cursor or animated cursor (.cur or .ani) file.
onwards and upwards...
|
|
|
|
|
Hi,
I'm using an older version of Han Yu's script that can be found on this website, however the problem I seem to be facing is the fact that it has problems when there are empty cells in the collumn. For instance it will do something like this:
12
13
14
9
10
1
5
7
As you can see, the script restarts its sorting routine after the empty cell. What I want is to have the empty cells sorted at the top or bottom (doesn't really matter seeing you can resort the table the otherway).
Does somebody have a solution to this? (the newer version of the script is much to slow and doesn't fix this problem either).
|
|
|
|
|
I want to print the Greek letter beta, so I do this: print ("\x{03B2}"). But I get some other weird characters (an "I" with a hat symbol, and a exponent "2")
|
|
|
|
|
I wanted to try out one of those starter kits on the asp.net website, but it told me I had to download MSDN...
So I did....
and when I click on the 'setup.exe' it comes up with a message box that say...
"A strong SA password is required for security reasons.
Please use SAPWD switch to supply the same. Refer to
readme for more details. Setup will now exit."
I checked the readme, but of course there's nothing there...
What is the solution???
/\ |_ E X E GG
|
|
|
|
|
I presume it's referring to the sa account -- an extremely high privilege account. This error message is an attempt to increase security by preventing DBAs from setting sa's password to something crappy.
As it says, you'll have to change the sa account password to something stronger, i.e. with 12 characters, numbers, symbols etc. After that it should be fine.
--
Paul
"Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office."
- David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk
Download my PGP public key
|
|
|
|
|
OK, gracias.
/\ |_ E X E GG
|
|
|
|
|
I wanted to develop web application using VS.NET. But my machine(win2000 pro) didn't have IIS installed, so I uninstalled VS.Net and trying to install IIS and then VS.Net. I don't have the win2000 pro CD, so I'm not able to install IIS from the control panel(add software components).Can someone give me the link to download IIS5.0 ?
|
|
|
|
|
If you don't have the CD, how did you get Win2K? I don't believe there's any site where you can download base components of Win2K like IIS5.0, but you may be able to work around the problem with the WebMatrix tool from Microsoft. It comes with a mini-server for developing and testing ASP.Net projects, and is freely available from www.asp.net[^].
"Welcome to Arizona! Drive Nice - We're Armed..." - Proposed Sign at CA/AZ Border
|
|
|
|
|