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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing an arg from an html form to print using javascript 2

Status
Not open for further replies.

Johnyed

Technical User
Aug 4, 2009
3
US
I'm not real good at java but heres what I'm trying to do.
I want to open a div using getElement WITH VARIABLES so I can write then into hidden form fields. The problem is I don't know how to pass the variables. Below is an example of what I'm trying to do but it is missing parts {the arguments as I don't know how to pass them}

Open html form
<form name="cart" action=" target="_blank" method="post">

Input button to display div
<input name="product" type="radio" value="z105n" onClick="document.getElementById('hideaway').style.display='block';">

Div
<div id="hideaway" style="display:block;">
<input type=hidden name=color value="
<SCRIPT LANGUAGE="JavaScript">
document.write(document.cart.product.value);
</script>
">
blah blah blah
</div>


Any advice would be greatly appreciated. I have no idea how to do this.
Thanks :)
John
 
Hi

John said:
I'm not real good at java but heres what I'm trying to do.
Neither us. But this is off-topic as this forum is not about Java.
John said:
I want to open a div using getElement
A [tt]div[/tt] can not be opened. The [tt]getElementById()[/tt] method opens nothing. So what you want exactly ?
John said:
so I can write then into hidden form fields.
You mean to set the [tt]value[/tt] of the [tt]input[/tt] ? To what exactly ?
John said:
The problem is I don't know how to pass the variables.
Which variables from where to where ?

Anyway, one guess :
HTML:
[b]<input[/b] [maroon]name[/maroon][teal]=[/teal][green][i]"product"[/i][/green] [maroon]type[/maroon][teal]=[/teal][green][i]"radio"[/i][/green] [maroon]value[/maroon][teal]=[/teal][green][i]"z105n"[/i][/green] [maroon]onclick[/maroon][teal]=[/teal][green][i]"document.getElementById('hideaway').style.display='block';[highlight]this.form.color.value=this.value[/highlight]"[/i][/green][b]>[/b]

Feherke.
 
I would start by learning the basics of HTML DOM & javascript (java is another language). w3schools is good place to start. From there I would also learn a js library(jquery, prototype, etc.). these libraries make it much easier to work with javascript. abstracting browsers is the biggest benefit.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Hi
Thanks for the advice. I'm going to try it a bit and see if I can get it to do what I need.

Thanks :)
John

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top