473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 3706
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_imgsrc');

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

var oInput = document.forms[...].elements['emListFull_imgsrc'];

Then build the `select' element:

var oSelect = document.createElement('select');
if (oSelect && oSelect.options)
{
oSelect.id = 'emListFull_imgsrc';
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.parentNode.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_imgsrc');


var oInput = document.getElementById('emListFull_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
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...
2
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
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...
12
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...
9
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...
1
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...
1
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. ...
7
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...
3
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.