473,387 Members | 1,545 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,387 software developers and data experts.

Javascript problem

how would i use document.write to write this input box? i can do it without
quotes but i need them for my purpose

<input type="textbox" name="input" value="something">

i did this but it doesn't have the double quotes
document.write( '<input type="textbox" name="input" ' + 'value="' +
entereddata+ '">');

2.
filter(enetereddate);
how can i filter out single quotes double quotes and other character that
might cause problem from a string? this string will be added to the value
param of the textbox.

this will cause problem, say i enetered this in a textbox

sjdkfjdfkd "dfdfd" dfdfd

when i do document.write and write this to the value parameter of the new
textbox it will be like this

<input type=textbox name=input value=sjdkfjdfkd "dfdfd" dfdfd>

i would like a function that can replace the quotes in the input string to
&quot;
and also any other harmful characters
Thanks in advance,
Aaron
Jul 21 '05 #1
1 1220
Hi,

First off, these are not the most appropriate groups for your question, but
anyway - see inline:

"Aaron" <ku*****@yahoo.com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
how would i use document.write to write this input box? i can do it without quotes but i need them for my purpose

<input type="textbox" name="input" value="something">

i did this but it doesn't have the double quotes
document.write( '<input type="textbox" name="input" ' + 'value="' +
entereddata+ '">');
You need to escape the quotes:

document.write( "<input type=\"textbox\" name=\"input\" value=\"" +
entereddata+ "\">");

2.
filter(enetereddate);
how can i filter out single quotes double quotes and other character that
might cause problem from a string? this string will be added to the value
param of the textbox.

this will cause problem, say i enetered this in a textbox

sjdkfjdfkd "dfdfd" dfdfd

when i do document.write and write this to the value parameter of the new
textbox it will be like this

<input type=textbox name=input value=sjdkfjdfkd "dfdfd" dfdfd>
If you use only double quotes you will need to escape only the double quotes
(it's easier). There is no ready function in jscript for this, but you can
use the replace function:

var v = "some \"NEW\" test";
var quot = new RegExp("\"", "g");
document.write("<input type=\"text\" id=\"input\" value=\"" +
v.replace(quot, "&quot;") + "\"><br/>");

Hope this helps
Martin

i would like a function that can replace the quotes in the input string to
&quot;
and also any other harmful characters
Thanks in advance,
Aaron

Jul 21 '05 #2

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

Similar topics

13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
6
by: Alex Rast | last post by:
First of all, this is not a programming question. I'm a user, not programming in JavaScript. I'm not, however, a novice user or even a power user - I certainly know programming intimately as well...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.