473,587 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repalce Input box by Javascript

Hi - I have a .net app, which uses a component - the component renders a
text box on a particular form.

I don't have the source code, so I can't recompile the dll.

From Javascript, can I place a function in the onload of the body, which
will search for a specific text box html, and replace it with a new
string (which would be a drop list)?

If so, how do I search for a specified string in the html of the page,
and delete it, and replace it with new html, from Javascript?

Thanks for any help,

Mark
*** Sent via Developersdex http://www.developersdex.com ***
Nov 23 '05 #1
6 3723
Mark wrote:
From Javascript, can I place a function in the onload of the body, which
will search for a specific text box html, and replace it with a new
string (which would be a drop list)?

If so, how do I search for a specified string in the html of the page,
and delete it, and replace it with new html, from Javascript?


I suggest you use W3C DOM Level 2 methods to retrieve a reference to the
respective DOM element object and to replace it with one that you see fit.

<http://www.w3.org/TR/DOM-Level-2-Core/core.html#i-Document>
<http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247>

Any hint as to which component you are using and what source code it
generates will be helpful.
PointedEars
Nov 23 '05 #2
Hi - sorry, didn't think it was important - but its the Easy Web editor
- which is just a WYSIWYG editor which I use to allow people to update
their page.

I use ASP.Net with VB - and the component simply renders an HTML box,
which is completely controlled client side by the Javascript it
produces.

I want to extend the image insert function - which currently simply
shows a DIV where you enter a filename (which must be local to the
server) and places it on the WYSIWYG editor window.

I've already written file upload sections for each customer, and I want
to replace the textbox input box which asks for the filename (which is
generated by the component), with a dropdown list which only lists the
image files uploaded by the current customer. I can do this server
side, and send an onload to the body to call a javascript function to
search and replace the textbox with my html for the drop down list - but
I just don't know how to do the search through the DOM and replace it
with the new HTML - I'll check out the links - but if the explanation
helps, I'd appreciate any guidance.

Thanks, Mark

*** Sent via Developersdex http://www.developersdex.com ***
Nov 23 '05 #3
Mark wrote:
Hi - sorry, didn't think it was important - but its the Easy Web editor
- which is just a WYSIWYG editor which I use to allow people to update
their page.

I use ASP.Net with VB - and the component simply renders an HTML box,
which is completely controlled client side by the Javascript it
produces.
Call me lazy, but why did you not even provide a URI again and have
me googling for that editor myself? <http://easy-web-editor.net/>

And no HTML code to operate on whatsoever. Am I supposed to buy
and setup that editor in order to help you? You bet I am not.
I just don't know how to do the search through the DOM and replace it
with the new HTML - I'll check out the links - but if the explanation
helps, I'd appreciate any guidance.


Provide the exact piece of HTML code you want to replace (View Source;
in Firefox you can even try View Selection Source) and the HTML code
you want to use instead and I'll see what I can do.
PointedEars
Nov 23 '05 #4
Hi PointedEars - thank you very much.

The original code is:

%lt;input type='text' id='emListFull_ imgsrc'/&gt;

The code I want to replace with is:

&lt;select id="emListFull_ imgsrc"&gt;
&lt;option value="cus94_1. png"&gt;Image 1&lt;/option&gt;
&lt;option value="cus94_2. png"&gt;Image 2&lt;/option&gt;
&lt;option value="cus94_3. png"&gt;Image 3&lt;/option&gt;
&lt;/select&gt;

I'm not a jsvascript programmer at all - so thank you for any help,

Mark

*** Sent via Developersdex http://www.developersdex.com ***
Nov 23 '05 #5
Mark wrote:
The original code is:

%lt;input type='text' id='emListFull_ imgsrc'/&gt;

The code I want to replace with is:

&lt;select id="emListFull_ imgsrc"&gt;
&lt;option value="cus94_1. png"&gt;Image 1&lt;/option&gt;
&lt;option value="cus94_2. png"&gt;Image 2&lt;/option&gt;
&lt;option value="cus94_3. png"&gt;Image 3&lt;/option&gt;
&lt;/select&gt;

I'm not a jsvascript programmer at all so thank you for any help,


That is not a good base to build on, is it? You should
definitely get yourself informed: <http://jibbering.com/faq/>

However, I take it that Developersdex's NNTP interface (AspNNTP 1.50)
which is known to be extremely buggy has escaped your valid markup
delimiters, therefore you probably want to replace

<input type='text' id='emListFull_ imgsrc'/>

with

<select id="emListFull_ imgsrc">
<option value="cus94_1. png">Image 1</option>
<option value="cus94_2. png">Image 2</option>
<option value="cus94_3. png">Image 3</option>
</select>

That would imply retrieving the reference to the `input' element with

var oInput = getElementById( 'emListFull_img src');

or, if you knew the `form' element it is a descendant of:

var oInput = document.forms[...].elements['emListFull_img src'];

Then build the `select' element:

var oSelect = document.create Element('select ');
if (oSelect && oSelect.options )
{
oSelect.id = 'emListFull_img src';
for (var i = 1; i < 4; i++)
{
oSelect.options[oSelect.options .length] =
new Option('cus94_' + i, 'Image ' + i);
}
}

and replace the `input' element with the `select' element:

oInput.parentNo de.replaceChild (oSelect, oInput);

Be sure to do proper feature tests on run time before you use any feature
described here. <http://www.pointedears .de/scripts/test/whatami>, § 2.
HTH

PointedEars
Nov 23 '05 #6
Thomas 'PointedEars' Lahn wrote:
var oInput = getElementById( 'emListFull_img src');


var oInput = document.getEle mentById('emLis tFull_imgsrc');

of course. (It's late, you know :))
PointedEars
Nov 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2862
by: J?rgen Jensen | last post by:
I have made an asp-page. When pressing Submit, the form loads a javascript, for evaluating the input values. The asp-page is being reloaded from the javascript, to save the input-values. The evaluation-script is running fine, but when the ASP-script has to save the value in txtFolder, the record is being added, but the saved value from input...
2
3068
by: reneeccwest | last post by:
Different user input boxes are automatically populated based on a value of the dropdown box. Can anyone help me on that?
3
5164
by: KathyB | last post by:
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form within the html document. When the Finish button is clicked, I need to check for any empty input boxes before loading the next aspx page...but it...
12
2287
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type text,text,radio,checkbox and select. When I run the following code, it correctly reports "text" (for input
9
1686
by: Igal | last post by:
hay. i have read some topics about this. but there's something i don't quite understand, if anyone can help. i have text, in it i want to highlight the words user used to find this result. i used the normal replace, it worked fine except the case thing... SearchForSp = Split(SearchFor, " ") For i = 0 to Ubound(SearchForSp) EmpJobsText =...
1
1370
by: DavidB | last post by:
Is there a way in VBA to determine if the standard Search replace dialog is open (Access 2003)? I have code that I need to run OnCurrent EXCEPT when the Search Replace dialog is opne and the user is utilizing the Repalce All function.
1
3986
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact...
7
7847
by: Joza | last post by:
Hi! How to replace dot with comma when user is typing somewhat in textBox? I have wrote this part of code to detect typed dot, but how to replace it with coma: private void txtNum_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (int)(char)'.') {
3
9859
by: zac540 | last post by:
Hey everyone! First of all I'd like to say that I did my best to look for any other relevant posts. The best I found was this interesting thread.. http://bytes.com/forum/thread594982.html If it answered my question I am just to stupid to realize it I would like to apologize in advance. This is my very first attempt at using Javascript so...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.