|
Hi... I have never used javascript before, so i think it's a bit difficult for me. But i promissed to help a friend who has created a web shop in java. With some kind of software, that has created his code. So the source is a mess.
My problem is when you have to type your customer adress, i want to open it in a new window, not in the iframe (That how it works know, i think..!)
I want customerdtl.html to open in it's own window
orderContentFrame.location="../customerdtl.html";
Hope someone can help af javascript newbie
|
|
|
|
|
Use the window.open method:
widow.open('../customerdtl.html', '_blank');
You can also use a thirt parameter, specifying the size of the window that is opened, and some other stuff.
Be aware that the form might rely on being opened in the iframe. You might have to change some of the code there also to make it work.
---
b { font-weight: normal; }
|
|
|
|
|
This method is used to open a new browser window
window.open('../customerdtl.html','name','height=200,width=150')
name is a string containing the name of the new window.
Kaushik Baruah is presently working as a Programmer Analyst in Cognizant Technology Solutions,Kolkata,India
-- modified at 7:03 Friday 30th September, 2005
|
|
|
|
|
I am having problems with the submit validation. I am returning a false however the page is still being submitted when I click on the okay button in the alert box.
I copied the code below.
Any help will be greatly appreciated!!!
-Sonia
function fnValidate(thisform)
{
with (thisform)
{
if (fnValidateText(sText,"Text ")==false)
{
sText.focus();
return false
}
}
function fnValidateText(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{
// concentanate alert name with name
alerttxt = alerttxt + "must be filled out!";
alert(alerttxt);
return false
}
else
{
// check if it is alphanumeric
alerttxt = alerttxt + "must contain one alphabet!");
alert(alerttxt);
return false
}
}
}
}
|
|
|
|
|
try -
onsubmit="return fnValidate(this);"
|
|
|
|
|
Hi,
I have a small HTML with a button and a handler object which is likely to catch the button's onclick event. When I try to click the button it says "this.button.id is null or not an object". If I do onclick="objHelper.buttonClick" in the "input type=button" tag instead it works fine. What is the right solution?
Here is my code:
<title>
function helper()
{
var button;
this.setButton = function(tobjButton)
{
this.button = tobjButton;
this.button.onclick = this.buttonClick;
};
this.buttonClick = function()
{
alert(this.button.id);
};
}
var objHelper = new helper();
function init()
{
objHelper.setButton(document.all("btnButton"));
}
Thanks:
(K)
|
|
|
|
|
Hi there,
When I try to click the button it says "this.button.id is null or not an object"
At the time the buttonclick function executes, the this keyword refers to the button object, not the objHelper . And the button object certainly does not contain any button member, so the this.button is undefined, then it should raise the error when you are accessing the this.button.id .
If I do onclick="objHelper.buttonclick" in the "input type=button" tag instead it works fine
Now you invoke the function buttonclick of the objHelper object, so the this keyword in the function should refer to the objHelper , and as a result it should be working as you expected.
To work around, you can simply change a bit your sample code:
this.buttonclick = function()
{
alert(this.id);
};
|
|
|
|
|
Hi everyone,
I have a problem on validation the controls in the datagrid. When I entered a control and enter an invalid value, the control will fire OnBlur event after I lost the focus of the control. It show me the alert message but the focus is not set back to the control that has the invalid value.
Anyone, please help me on how to set back the focus on the control with the invalid value after the alert message is showed, so that the user will immediately know he had entered an invalid value. Below is my javascript
function vldValue(args)
{
var IsValid;
var validFormatRegExp = /^((\-)\d)?\d*(\.\d{3})?$/;
IsValid = validFormatRegExp.test(args);
alert("Invalid Value!");
return IsValid;
}
thanks a lot in advance.
Chiari
|
|
|
|
|
Hi there,
Basically, to set the focus on an element, you can simply call the object.focus() method, so to set the focus back to the control that has an invalid value, you need to get reference to the control, then invoke the focus() method.
|
|
|
|
|
Hi,
I have tried to set the focus by using object.focus() method, it doesn't work on controls in datagrid. Simply, I can't found any reference of the control. It prompt an error as null.
By the way, do you know the code of using SendKeys in javascript?
Thanks a lot,
Chiari
|
|
|
|
|
How do you get the value of the input control to validate? IMO, if you can access the value of the control to validate, then you probably have an idea how to access the control via its id, name ..., the sample code looks something like:
...
var txtBox = document.getElementById("datagrid1_ctl1_txtUserName");
txtBox.focus();
... AFAIK, there is no method in javascript that behaves like the SendKeys method in the window-based application. However, you can catch up the events when the user presses the keys and determine which keys are pressed.
|
|
|
|
|
Hi,
I tried using it but it return null value. Ok... My datagrid id is 'dgStkcode' and the id/name of the control inside this datagrid is 'EditAsCast'. So is it rite for me to write the code as
...
var txtbox = document.getElementById("dgStkcode_ctl1_EditAsCast");
txtbox.focus();
...
Please correct me.
I tested out something.
When the code is
...
var txtbox = document.getElementById("dgStkcode");
...
It return [object] to me. Does this means it got the id of the datagrid?
Thanks a lot
Chiari
|
|
|
|
|
Chiari wrote:
My datagrid id is 'dgStkcode' and the id/name of the control inside this datagrid is 'EditAsCast'...
Basically, you can use the getElementById method to get reference to an html element at the client side based on its id. To know exactly what the id of the input textbox is, you simply view source the web page in the browser. In fact, this value is the value of the ClientID property of the control.
Chiari wrote:
It return [object] to me. Does this means it got the id of the datagrid?
It means the method found an object whose id is the dgStkcode .
How do you get the value of the input textbox to validate btw?
|
|
|
|
|
I passed in the parameter to it when calling the function.
onblur="return vldValue(this.value)"
Chiari
|
|
|
|
|
You'd better pass the object (this) instead of its value (this.value) as the method parameter so that you can use the object to change the background color without having to retry to get reference to the control again. The sample code looks something like:
....onblur="return vldValue(this)"....
function vldValue(obj)
{
var value = obj.value;
....
if(!isValid)
obj.style.backgroundColor = "red";
...
}
|
|
|
|
|
Hi,
Your advice really help me a lot. I'm able to get the reference to the control.
Thanks a lot,
Chiari
|
|
|
|
|
I found this bug in my javascript form,which is Data Entry form which send info to MS Outlook and send the mail,when trying to enter a semicolon(") in the textbox,MS outlook returns this error.
"The command line argument is not valid.Verify the switch you are using"
Can anyone solve this?
-- modified at 3:13 Thursday 29th September, 2005
|
|
|
|
|
Could it be because semi-colon usually denotes end of a line in javascript, thus the script thinks that the line ends with the semi-colon and then tries to interprete the following text as code lines?
Try escaping your semi-colon and see what it does.
---------------------------
127.0.0.1 - Sweet 127.0.0.1
|
|
|
|
|
The whole form works perfectly without the semi-colons,when i tried entering one semi-colon,all data(below the form) that was suppose to appear, all gone under the MS outlook.
|
|
|
|
|
This (") is not a semicolon ( ; ), it is a quote.
Quotes are probably used around the value when it's sent as a string value. In that case you have to escape the quotes in the value. How that is done depends on how you are sending the data.
---
b { font-weight: normal; }
|
|
|
|
|
How can i solve this problem? I have a send Mail function was sends data through this code from form to Outlook:
isBody += "Employee Name: " + isForm.personal.value +"%0D%0A";
document.forms.Send.action = "mailto:"+recipient+"?subject="+isSubject+"&body="+isBody+" ";
isForm = Form name
personal.value = textbox field name
|
|
|
|
|
Use the escape() function on the values. That will url encode the characters that needs encoding.
---
b { font-weight: normal; }
|
|
|
|
|
Can u quote me an example???
|
|
|
|
|
isBody += "Employee Name: " + isForm.personal.value +"%0D%0A";<br />
document.forms.Send.action = "mailto:"+escape(recipient)+"?subject="+escape(isSubject)+"&body="+escape(isBody)+" ";
---
b { font-weight: normal; }
|
|
|
|
|
Hi there!
I am trying to save different .swf files on my local machine.
Actually this is already working with the below code.
Unfortunately (how I already figured while writing the code) The file is saved, but somehow corrupted.
Is there maybe a way more simple way to get the Response of an URI into a string (or, let's say a buffer) and save it on my disk?
Below is the code I came up with (within a C# web application):
// init
bool debug = false;
// this is where I get my test-swf, you can have a look at it at:
// http://www.styte.com/3.swf
// it may look strange, what I am trying to do is to read some php-created
// swf's into my .net application....
string url = "http://www.styte.com/trans.php?&bild=3.swf";
// work
Uri fileUrl = new Uri(url);
// Create 'FileWebrequest' object with specified Uri.
WebRequest myFileWebRequest = (WebRequest)WebRequest.Create(fileUrl);
// Send 'FileWebRequest' object & wait for response.
WebResponse myFileWebResponse = (WebResponse)myFileWebRequest.GetResponse();
// Get stream object associated with response object.
Stream receiveStream = myFileWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("windows-1252"); //("utf-8");
// Pipe stream to higher level stream reader with req. encoding format.
StreamReader readStream = new StreamReader (receiveStream, encode);
if (debug==true) Response.Write("\r\nResponse stream received<br>");
int numChars = 1;
Char[] read = new Char[numChars];
// Read "numChars" characters at a time.
int count = readStream.Read ( read, 0, numChars );
if (debug==true) Response.Write("(count): "+count.ToString()+" File Data...\r\n");
//Response.ContentType = "application/x-shockwave-flash";
//Response.AddHeader("Content-Type", "application/x-shockwave-flash");
FileStream fs = File.Create(@"C:\Inetpub\wwwroot\leilac\uploads\test.swf");
BinaryWriter bw = new BinaryWriter(fs);
while (count > 0) {
String str = new String(read, 0, count);
bw.Write(str);
Response.Write(str);
count = readStream.Read(read, 0, numChars);
}
bw.Close(); fs.Close();
if (debug==true) Response.Write("<br>");
// Release resources of stream & response object.
readStream.Close();
myFileWebResponse.Close();
Response.End();
Appreciate any comments/help.
Sascha Stanscheit, styte, http://www.styte.com/
|
|
|
|