473,810 Members | 2,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="somethin g">

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

2.
filter(enetered date);
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=sjdkfjdfk d "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 1245
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******** ******@TK2MSFTN GP12.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="somethin g">

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(enetered date);
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=sjdkfjdfk d "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
9467
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 intercept the key so that I can do stuff on the server side to make the new window behave correctly? (We have a JSP-based webapp which stores state in the session. Now if two windows access (and modify!) the same session, then madness will result....
53
5758
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 difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
6
2283
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 as computer hardware, configuration, etc... down to the lowest level (e.g. BIOS, assembly language, etc). Anyway, I've obviously got something wrong with JavaScript configuration, files, etc. in Windows 2000, Service Pack 3, because on sites...
136
9468
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
0
9722
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10378
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10391
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
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
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.