Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling functions within functions using document.write

Status
Not open for further replies.

subzero2k35

Technical User
Joined
Nov 10, 2001
Messages
3
Location
GB
Im trying to construct a page on my website which allows the viewer to select a style of Alloy Wheel from a list (this is done in HTML), each Alloy wheel has 5 different sizes (14", 15" 16" 17" 18") which have different Price values.

Once they have selected a Allow Whee the next page shows the Wheel with the 5 different prices, here they must select the size and quantity.

(This is where ive got a problem):The next page should show the chosen wheel, the size and price relating to the quantity.

Ive written they first page in HTML which calls a function to handle the second page.

im using
document.write('<a href=&quot;#&quot; onClick=&quot;thirdPage(values)&quot;>BUTTON</a>')
to handle the selection and jump to the third page.
but im getting error messages Object expected.

If i replace the onClick to onClick=alert(values) i can get the alert box to show the values.

anyway im just wondering if im wasting my time trying to call a function from with a function using document.write??

or does anyone have a much simplier way of achieving what im after??

Thanks

Sub.
 
Just make sure you have the function defined, and spelled correctly.
 
try ...

document.write(&quot;<a href='#' onClick='&quot; + thirdPage(values) + &quot;'>BUTTON</a>')
 
ive sort of done it??

i have put all the functions in 1 remote file (script.js)

i have used:

<HTML>
<script language=&quot;javaScript src=&quot;script.js&quot;>
</script>

in the first page.

documet.write('<script language=&quot;javaScript src=&quot;script.js&quot;>)'
document.write('</scri')
document.write('pt>')

in the second and so on..

but each time a new page loads via the document.write all the variable values are lost.

How do i keep all values from one page to another?? is this possible in javaScript?

Thanks
 
If I understand you right, you are hoping to keep the values stored in a variable in an external .js file. I'm pretty sure that each new page reloads that file: all previous values are discarded.

I've done something like this, and the solution I found was to hold the page in a frame. That way, one frame you can keep constant (the one with your javascript and variables) and the other can be loaded with whatever you want and pull values from the other frame.

The other option is cookies... And it works fine so long as they're enabled.

Or, you could just go all javascript/DHTML (using innerHTML and what not) and never reload the page. Granted that leaves out opera, Ns -4.x, and IE -3, so it's not really a good option unless your viewers are all IE4+ or NS6+.

hope I've helped..

Jhereg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top