473,734 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with some script

CAn Some one please help when this scrip runs it does not enter the data
from my forms, it just says[object] where each feild should be. I have
tested it using google address and it appears to work just fine. But i
cma't get it to work with the below link.

Thanks james
<script>
function doURL() {
ncheckInDate=do cument.getEleme ntById("checkIn Date").value
ncheckInMonth=d ocument.getElem entById("month" ).value
ncheckInYear=do cument.getEleme ntById("year"). value
nnumberOfNights =document.getEl ementById("nigh ts").value
nnumberOfAdults =document.getEl ementById("adul ts").value
nnumberOfRooms= document.getEle mentById("rooms ").value

t="http://www.ichotelsgro up.com/redirect?checkI nDatebrandCode= 6c&path=asearc
h&city=London&c ountryId=0925&r ateTypeCodes=6C BARC&checkInDat e="+checkInDate +
"&checkInMonth= "+month+"&check InYear="+year+" &numberOfNights ="+nights+"&num b
erOfAdults="+ad ults+"&numberOf Rooms="+rooms+" &hotelCode=LONL H"

alert(t)
location.href=t
}
</script>
Jul 20 '05 #1
6 1291
Hello,
ncheckInDate=do cument.getEleme ntById("checkIn Date").value It seems the getElemenetById ("checkInDate") .value is returning an object and
not a value.
Try accessing the values of your 'checkInDate' and similar fields through
their form as:
theForm['checkInDate'].value

--
Elias

"james" <ja***@legeo.co .dh> wrote in message
news:br******** **@titan.btinte rnet.com... CAn Some one please help when this scrip runs it does not enter the data
from my forms, it just says[object] where each feild should be. I have
tested it using google address and it appears to work just fine. But i
cma't get it to work with the below link.

Thanks james
<script>
function doURL() {
ncheckInDate=do cument.getEleme ntById("checkIn Date").value
ncheckInMonth=d ocument.getElem entById("month" ).value
ncheckInYear=do cument.getEleme ntById("year"). value
nnumberOfNights =document.getEl ementById("nigh ts").value
nnumberOfAdults =document.getEl ementById("adul ts").value
nnumberOfRooms= document.getEle mentById("rooms ").value

t="http://www.ichotelsgro up.com/redirect?checkI nDatebrandCode= 6c&path=asearc h&city=London&c ountryId=0925&r ateTypeCodes=6C BARC&checkInDat e="+checkInDate + "&checkInMonth= "+month+"&check InYear="+year+" &numberOfNights ="+nights+"&num b erOfAdults="+ad ults+"&numberOf Rooms="+rooms+" &hotelCode=LONL H"

alert(t)
location.href=t
}
</script>

Jul 20 '05 #2
"james" <ja***@legeo.co .dh> wrote in message
news:br******** **@titan.btinte rnet.com...
CAn Some one please help when this scrip runs it does not enter
the data from my forms, it just says[object] where each feild
should be. I have tested it using google address and it appears
to work just fine. But i cma't get it to work with the below link.

Thanks james
<script>
function doURL() {
ncheckInDate=do cument.getEleme ntById("checkIn Date").value
Above you are creating a global variable with the name "ncheckInDa te"
and assigning a value to it (assuming that the browser in use supports
document.getele mentById and the call to that method returns an object
reference, neither of which are certain). Needlessly creating global
variables (indeed, giving variables any more scope than the absolute
minimum (possible) they need) is bad programming. Prefixing the
statement with the - var - keyword would declare the variable local to
the function.
ncheckInMonth=d ocument.getElem entById("month" ).value
Ditto.
ncheckInYear=do cument.getEleme ntById("year"). value
Ditto.
nnumberOfNights =document.getEl ementById("nigh ts").value
Ditto.
nnumberOfAdults =document.getEl ementById("adul ts").value
Ditto.
nnumberOfRooms= document.getEle mentById("rooms ").value

t="http://www.ichotelsgro up.com/redirect
?checkInDatebr andCode=6c&path =asearch&city=L ondon&
countryId=0925 &rateTypeCodes= 6CBARC&checkInD ate="+checkInDa te+
Above you have created a global variable with the identifier
"ncheckInDa te" and assigned it the value property of a (presumably form
element) object (assuming browser support for the method used and
correctly corresponding HTML). Here you are concatenating the value held
by the identifier "checkInDat e" to the string. In fact you do not appear
to be using any of the global variables created above in assembling this
string.

If we assume that the (unseen) HTML does contain a form element with the
ID "checkInDat e", as is implied by the first call to the getElementById
method, then some browsers (IE and followers) will have made a reference
to that element into a global property with the name "checkInDat e" and
the use of that identifier here will be resolved into a reference to
that object. On IE almost all native objects type-convert to the string
"[object]", which explains the reported results.

The balance of probability is that you should be concatenating the
global (but should be local) variable values into this string (otherwise
there was not much point in creating them). However, if this string is
going to be used as a URI (which it is) the values in the name/value
pairs may need to be URI encoded, unless you have already verified that
they only contain characters that would not be altered by URI encoding
(it is user input so it could be anything).
"&checkInMonth ="+month+"&chec kInYear="+year+
Ditto. ... etc.
"&numberOfNigh ts="+nights+
"&numberOfAdul ts="+adults+
"&numberOfRoom s="+rooms+"&hot elCode=LONLH"

alert(t)
location.href=t


Absolutely none of this is necessary, an appropriate HTML form and a
properly constructed back-end could (and so should) do this job without
even involving JavaScript, and do it better and more reliably. If this
is a genuine hotel booking system (rather than an academic/training
exercise that will never be used) you should bare in mind that your
ignorance of what you are doing will directly result in an _unnecessary_
and _avoidable_ loss of business for whoever it is that is employing
you.

Richard.
Jul 20 '05 #3
lallous wrote:
ncheckInDate=do cument.getEleme ntById("checkIn Date").value It seems the getElemenetById ("checkInDate") .value is returning an object and
not a value.


It does not seem so, and would contradict any DOM specification I have
read anyway. However, it is possible that document.getEle mentById(...)
returns, if supported, an undefined (!= `undefined') value if there is
more than one element with that ID or a `null' value if there is none
element with that ID. Thus one should always check the returned
reference before accessing the object it references:

if (document.getEl ementById)
{
ncheckInDate = document.getEle mentById(...);

/*
* Checks for a valid reference; can include combination with checks
* for value to see that we got the correct object; however, using
* multiple identical IDs is bad style if not even invalid HTML.
*/
if (ncheckInDate && typeof ncheckInDate.va lue != "undefined" )
{
... ncheckInDate.va lue ...
}
...
}

This is a general method and of course applicable
but not efficient with form elements at all, since:
Try accessing the values of your 'checkInDate' and similar fields through
their form as:
theForm['checkInDate'].value
Assuming that `theForm' is a reference to the HTMLFormElement object,
the standardized and therefore recommended method of accessing one of
its child form elements is

theForm.element s['checkInDate']
--
A trailing space is needed for that to be a signature separator.
Since OE is borken on that, you require additional tools or should
just leave it out.
[...]
[TOFU]


Please stop doing that, bandwidth and disk space are precious. Instead,
trim your quotes to the parts you are referring to and place the answer
below the "question" as you see here.
PointedEars
Jul 20 '05 #4
JRS: In article <br**********@t itan.btinternet .com>, seen in
news:comp.lang. javascript, james <ja***@legeo.co .dh> posted at Thu, 11
Dec 2003 07:58:59 :-
CAn Some one please help when this scrip runs it does not enter the data
from my forms, it just says[object] where each feild should be. I have
tested it using google address and it appears to work just fine. But i
cma't get it to work with the below link.
Please check your English before posting. Do not allow your posting
agent to break code lines. Use layout in your code for legibility,

function doURL() {
ncheckInDate=do cument.getEleme ntById("checkIn Date").value
ncheckInMonth=d ocument.getElem entById("month" ).value
ncheckInYear=do cument.getEleme ntById("year"). value
nnumberOfNights =document.getEl ementById("nigh ts").value
nnumberOfAdults =document.getEl ementById("adul ts").value
nnumberOfRooms= document.getEle mentById("rooms ").value

t="http://www.ichotelsgro up.com/redirect?checkI nDatebrandCode= 6c&path=asearc
h&city=London& countryId=0925& rateTypeCodes=6 CBARC&checkInDa te="+checkInDat e+
"&checkInMonth ="+month+"&chec kInYear="+year+ "&numberOfNight s="+nights+"&nu mb
erOfAdults="+a dults+"&numberO fRooms="+rooms+ "&hotelCode=LON LH"

alert(t)
location.href=t
}


Your last line should be written as

t = "http://www.ichotelsgro up.com/redirect?checkI nDatebrandCode= 6c" +
"&path=asearch& city=London&cou ntryId=0925&rat eTypeCodes=6CBA RC" +
"&checkInDa te=" + checkInDate +
"&checkInMonth= " + month +
"&checkInYe ar=" + year +
"&numberOfNight s=" + nights +
"&numberOfAdult s=" + adults +
"&numberOfRooms =" + rooms +
"&hotelCode=LON LH"

Code that is illegibly-written is unlikely to be error-free.

It is now obvious that you have, at the right of six lines, names of
form objects rather than the values you have read from them.
ncheckInDate=do cument.getEleme ntById("checkIn Date").value

and its mates are rather repetitive. ISTM that one should be able to
write (untested)

function Read(S) { return document.getEle mentById(S).val ue }

ncheckInDate = Read("checkInDa te")
ncheckInMonth = Read("month")
// ...

and even end up with

t = ... +
"&checkInDa te=" + Read("checkInDa te") +
"&checkInMonth= " + Read("month") +
...

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> Jsc maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/Jsc/&c, FAQ topics, links.
Jul 20 '05 #5
On Fri, 12 Dec 2003 21:01:56 +0000
Dr John Stockton <sp**@merlyn.de mon.co.uk> wrote:
<snip>
Please check your English before posting. Do not allow your posting
agent to break code lines. Use layout in your code for legibility,
It looked to me like English was his second language, and much better
than my German.

<snip> Your last line should be written as

t = "http://www.ichotelsgro up.com/redirect?checkI nDatebrandCode= 6c" +
"&path=asearch& city=London&cou ntryId=0925&rat eTypeCodes=6CBA RC" +
"&checkInDa te=" + checkInDate +
"&checkInMonth= " + month +
"&checkInYe ar=" + year +
"&numberOfNight s=" + nights +
"&numberOfAdult s=" + adults +
"&numberOfRooms =" + rooms +
"&hotelCode=LON LH"

Code that is illegibly-written is unlikely to be error-free.


I suspect it probably was written something like your reformatted code
above and had been run through a utility to discard extra white space to
minimize download time.
<snip>
--
"Rats and roaches live by competition under the laws of supply and
demand. It is the privilege of human beings to live under the laws of
justice and mercy."
- Wendell Berry
Jul 20 '05 #6
JRS: In article <20************ *************** ***@tcac.net>, seen in
news:comp.lang. javascript, Albert Wagner <al******@tcac. net> posted at
Fri, 12 Dec 2003 20:27:16 :-
On Fri, 12 Dec 2003 21:01:56 +0000
Dr John Stockton <sp**@merlyn.de mon.co.uk> wrote:
<snip>
Please check your English before posting. Do not allow your posting
agent to break code lines. Use layout in your code for legibility,
It looked to me like English was his second language, and much better
than my German.


Possibly so; but he is posting as James, via a British ISP, and should
know better. One cannot expect a high literary standard from the
recently-educated, but one who purports to be a programmer should at
least be careful.
<snip>
Your last line should be written as
...
Code that is illegibly-written is unlikely to be error-free.


I suspect it probably was written something like your reformatted code
above and had been run through a utility to discard extra white space to
minimize download time.


Possibly so. But, in that case, the compressed version should be used
only for download, and the legible version should be retained for
update, reading, discussion, and improvement.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
Jul 20 '05 #7

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

Similar topics

9
4338
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side vbscript reads the database and populates a listbox on the page with the first field from each record in the recordset. This works fine. - User selects an option on the listbox and, using the OnChange, I
53
4458
by: Andrew Poulos | last post by:
I've got some CSS that looks like this: body { margin: 0; font-family: Arial, Helvetica, sans-serif; font-size: 140.01%; color: #000000; } but IE won't apply the font size to text in table cells so I've had to
8
2568
by: rdlebreton | last post by:
Hi, Folks! I've been trying to develop my own version of these draggable layers and I have been limiting myself to IE6...for now. I have looked at some other examples to get ideas of creating an alternative to pop-up windows in a web page. The code I have works (sort of). The problem is that I can move these layers around when I move the mouse slowly, however, if I move it fast the web browser looses track of the motion and leaves the...
1
4967
by: Ryan Stewart | last post by:
If you don't want to read this post because of its length, I understand. I've spent two and a half days on this problem and have a good deal of information to relate. And this is kind of a long shot, but I'm just hoping someone here has experienced a similar problem and has a better idea of what's going on than I do. First, I've tested this in IE 6.0, Netscape 7.2, Mozilla 1.75, and Firefox 1.0. It works fine in IE (even though I was...
13
1892
by: nobody | last post by:
Hello all, I've searched just about everything and although I can see that other people are having problems, but theirs don't seem to relate, so in a last ditch attempt, my posting! Script tags are hanging in ie when generating a html page in a new window. Works fine in netscape/moz. I know ie does some weird things with scripts but...
3
2611
by: krzychu | last post by:
Hi, I have installed brand new platform - Zope-2-7-6, Python 2.4.1, Plone 2.0.5, OS Debian 1:3.3.6-2. After import a old Plone site from the following platform Zope-2-7-4, Python 2.3.3, Plone 2.0.3 to the new one, I get error when I visit PuthonScript in the ZMI. "invalid syntax (Script (Python), line 1)"
5
2735
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
9
2401
by: Jerim79 | last post by:
Here it is: <?php if($_SERVER=='POST'){ $Number=$_POST; $Email=$_POST; $Number2=0; $error=0;
1
3752
by: skyson2ye | last post by:
Hi, guys: I have written a piece of code which utilizes Javascript in PHP to create a three level dynamic list box(Country, States/Province, Market). However, I have encountered a strange problem, and I have spent three days trying to debug but to no avail. Everything is OK when there are only two dependent list boxes, but when adding the third child list box, a problem appears: if I populate the third box only with the value: new...
0
8776
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9310
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...
0
8186
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
6735
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
6031
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
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
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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
2180
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.