|
First I will tell you what I have done:
I have a "<select>" control in my web page.
Now I want to change the content of this control dynamically in javascript.
So I tried for testing purpose the following:
I call the function doit() in the onload event of the body tag.
function doit() {
window.setTimeout("_doit()", 500);
}
function _doit() {
alert (document.getElementById ("PT_multivalue2").outerHTML);
document.getElementById ("PT_multivalue2").innerHTML = "huhuhu <option value='1'>eh</option> <option value='2'>eh2</option>";
alert (document.getElementById ("PT_multivalue2").outerHTML);
document.getElementById ("PT_multivalue2").outerHTML = document.getElementById ("PT_multivalue2").outerHTML.replace ("huhuhu", "");
}
So now for explanation:
My 1st try was to set the option list "<option value='1'>eh</option>" als innerHTML. => result: There was no entry in the select control.
My 2nd try was to add the 2 alert statement to see what javascript is doing. And the result was, that innerHTML was only "eh</option>" => the first option tag was missing.
So, I've done the following: I added "huhuhu" at the beginning of the option list. After setting this as innerHTML I replaced the "huhuhu" with "" in the outerHTML attribute.
Do you have any ideas, why the first part of the string is cutted fom innerHTML while setting this attribut.
Thanks in advance.
Erik
|
|
|
|
|
I have tried your sample. It works.
--------------------------------------------------------------------
Javascript Source
=================
<script type="text/javascript">
function addOptions(){
document.getElementById ("PT_multivalue2").innerHTML = "<option value="1">eh</option><option value="2">eh2</option>";
}
</script>
--------------------------------------------------------------------
HTML Source
===========
<input id="Button6" type="button" value="button" onclick="addOptions();" />
<select id="PT_multivalue2">
</select>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
|
|
|
|
|
I made the following test again.
This is my complete content of my HTML file.
----------------------------------------------------------------
<html>
<head>
<title>Sollterminlaufzeiten</title>
<script language="javascript">
function addOptions() {
document.getElementById ("CodeProjTest").innerHTML = "< option value='1'> eh< /option> < option value='2'> eh2< /option> ";
alert (document.getElementById ("CodeProjTest").innerHTML);
}
</script>
</head>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="TargetDateRuntimeConfig.aspx" id="Form1">
<input id="Button6" type="button" value="button" onclick="addOptions();" />
<select id="CodeProjTest"></select>
</form>
</body>
</html>
----------------------------------------------------------------
It still doesn't work.
The alert message box shows the following:
< option value='1'> eh< /option> < option value='2'> eh2< /option>
Do you have any ideas what the problem could be? Maybe you can tell me, what a
alert shows in your example.
Thanks for your help.
Erik
|
|
|
|
|
ieaeitsch wrote: < option value='1'>
1. don't add " " (whitespace) between
2. use \" instead of ' (eg. value=\"1\")
See the example in my next post.
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<script type="text/javascript">
function addOptions() {
document.getElementById("CodeProjTest").innerHTML = "<option value="\"1\""> eh</option> <option value="\"2\"">eh2</option> ";
alert(document.getElementById("CodeProjTest").innerHTML);
}
</script>
</head>
<body>
<form name="Form1" method="post" action="TargetDateRuntimeConfig.aspx" id="Form1">
<input id="Button6" type="button" value="button" onclick="addOptions();" />
<select id="CodeProjTest"></select>
</form>
</body>
</html>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
|
|
|
|
|
I tried exactly what you said...
Know I don't have the HTML-Code "<" for "<", what is good.
But now I have the problem from the beginning again. The first option-tag is missing. I don't know what I make wrong.
I've now tested the HTML-page on another computer, because I thought maybe it is a problem with my PC. But it doesn't work also on the other PC.
Do you have any suggestions what goes wrong?
Thanks and Regards,
Erik
|
|
|
|
|
The problem is solved.
I tried the HTML-page in Firefox and it works. It is a bug in Internet Explorer.
Thank you very much for your help.
Erik
|
|
|
|
|
Oh. that's why. I'm Firefox user so I forgot to check my script in IE.. ya.. this way doesn't work on IE..
|
|
|
|
|
You probably should write like that.
function addOptions()<br />
{<br />
var sel = document.getElementById("CodeProjTest");<br />
sel.options.length = 0;<br />
<br />
for (var i=0; i<5; ++i){<br />
sel[sel.options.length] =<br />
new Option('Option ' + i, 'opt' + i, (i==2), (i==4) );<br />
}<br />
}
Ref : http://www.thescripts.com/forum/thread453749.html[^]
|
|
|
|
|
I think you should read this[^] article.
Wout Louwers
|
|
|
|
|
Thank you for this hint. Now it is clear, why my page doesn't work.
Thanks and Regards,
Erik
|
|
|
|
|
Hi Guys,
Do you have any idea if how can i open the "Choose File" window in ASP.Net VB type of coding? Because the only control that can open the "Choose File" window is the Upload control. But I only need a button wherein the user will click on it and then a "Choose file" window will show up.
Do you know some work around about this, or a third-party control outthere?
Thanks Guys
hifiger2004
|
|
|
|
|
This control provides an ASP.NET wrapper aound the standard HTML file upload control. Unless you want to purchase a 3rd-party component, you are limited by the functionality provided by the HTML form elements.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
I am using ajax update panels .there are 11 update panels in one page.8 having 'always' updatemode and 3 having 'Conditional' update mode.i also made a ScriptMode="Release" in script manager but the performance of this page is very poor.How i improve the performance of this page
|
|
|
|
|
thanks so much for useful info
http://globolstaff.com
|
|
|
|
|
change EnableViewState="false"
when you use update panel
Every post back time viewstate value(Hidden field) value send to server side. and it again pass the viewstate value to browser.
so avoid EnableViewState="true"
|
|
|
|
|
Can anyone tell me if I can call a 2005 web service using an existing VB.NET 2003 application.
I want to create my web service in the up to day technology for longevity & to use the zipping facilities, but an existing 2003 app will need to use it.
Are there any issues I need to be aware of.
Any advice would be welcomed.
BlueMeanie
modified on Tuesday, December 11, 2007 6:10:18 AM
|
|
|
|
|
BlueMeanie1878 wrote: Can anyone tell me if I can call a 2005 web service using an existing VB.NET 2003 application.
Yes, you can.
BlueMeanie1878 wrote: Are there any issues I need to be aware of.
As long as the public interface for your web service doesn't expose any data types that are incompatible with .NET 1.0/1.1, you shouldn't have any problems.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Suppose i have created two html pages and i want to provide event handling in that. Suppose i want to connect to the second page from the first page and i want to do that with a java servlet. How to do that.
skd
|
|
|
|
|
Your best bet is to pass values between the pages using HTML.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi
i am using Autosuggest Controlin my project
i want that on entering some text in text box, suggestion is comming but it streches the table. I solved it by using "Div" so it comes over control, i am happy.
But now that div control, should be exactly below textbox, but it is placed left of textbox, i try to used style, css but didnt got success
so please help me
I fed up to do that, so give me any idea.
thanks!
|
|
|
|
|
What about adding the <br> after textbox?
|
|
|
|
|
Hi Guys,
How can I display the message in C#?
example:
MsgBox("oliver")
Thanks
hifiger2004
|
|
|
|
|
In Javascript, you'd do something like:
alert("oliver")
That doesn't answer your question, but it does answer the Web Development Forum version of your question...
|
|
|
|
|
You cant use C# to show a messagebox/alert in a webapplication. C# is serverside-code and to show a messagebox you will have to use client-side code.
User javascript
alert("Hello!");
if you have to use dynamic text you can read more about it at http://msdn2.microsoft.com/en-us/library/ms178207.aspx[^]
If a windows form you can use:
System.Windows.Forms.MessageBox.Show("Hello");
|
|
|
|