Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Access hidden form value?

New Here ,
May 29, 2007 May 29, 2007
hey guys
I was hoping someone could answer me a quick question. How do I access a hidden form's value from coldfusion? I have setup my hidden form using <input type="hidden" name="index_num" value="0" />
then I need to have coldfusion pull the value from that hidden input form. Any ideas? I tried to use FORM.index_num, but that gives an error...

more in depth, I'm calling it from a javascript function:
function thisOne() {
var #toScript ( myArray [ FORM.index_num ], "jsArray" );
}

thanks alot
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2007 May 29, 2007
The fact that the form is hidden is irrelevent. If you submit the form, hidden field will be submitted just like text boxes, selects, etc.

If you are trying to access it on the form page, there are a couple of options. One, is to determine how you came up with the value in the first place and either do it again, or use the same variable. If you do want to use javascript, you do it the same way as any other form field, including the part where you make your attempt after the form has been written to the web page, not after.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2007 May 29, 2007
What is the error?
Do you have the function wrapped in cfoutput as I don't see it around that
line of code?
Could the error be related to the closing # not being there?
Is it WDDX related? If so, have you included the wddx.js file?

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technology, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/



"drj85" <webforumsuser@macromedia.com> wrote in message
news:f3i68o$pef$1@forums.macromedia.com...
> hey guys
> I was hoping someone could answer me a quick question. How do I access a
> hidden form's value from coldfusion? I have setup my hidden form using
> <input
> type="hidden" name="index_num" value="0" />
> then I need to have coldfusion pull the value from that hidden input form.
> Any
> ideas? I tried to use FORM.index_num, but that gives an error...
>
> more in depth, I'm calling it from a javascript function:
> function thisOne() {
> var #toScript ( myArray [ FORM.index_num ], "jsArray" );
> }
>
> thanks alot
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2007 May 29, 2007
drj85 wrote:
> hey guys
> I was hoping someone could answer me a quick question. How do I access a
> hidden form's value from coldfusion? I have setup my hidden form using <input
> type="hidden" name="index_num" value="0" />
> then I need to have coldfusion pull the value from that hidden input form. Any
> ideas? I tried to use FORM.index_num, but that gives an error...
>
> more in depth, I'm calling it from a javascript function:
> function thisOne() {
> var #toScript ( myArray [ FORM.index_num ], "jsArray" );
> }
>
> thanks alot
>

You don't call coldfusion variable from a javascript function!
JavaScript runs on the client and you need to use DOM syntax to access
the form data. And if this function is on the action page, that page is
not going to have the form any more, unless you have rebuilt it with html.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 30, 2007 May 30, 2007
Thanks for all your replies. What I'm trying to accomplish is using the hidden form field to store a variable. The javascript determines what the index should be, and sets the value of the hidden form field. That part works fine. The part taht doesn't work is: my coldfusion script needs to be able to see or pull the variable so it can use that index into an array.

I can't use submit because I don't want the page to reload everytime. Everywhere I look theres talk of using a form field for javascript, but no real examples of it. Sorry, I'm new to coldfusion (2 weeks), so I'm still trying to figure it all out.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 25, 2007 Oct 25, 2007
LATEST
Not sure if this is what you're getting at, but something like the following very ugly code designed to just convey the principle might help:

<script>
function SendHiddenFields()
{with (document.myform
{
myvar = "xyz";
my_hidden_field.value = myvar;
submit();
}
}
</script>
<html>
<form name="myform" action="destination.cfm" method="post">
<input type="hidden" name="my_hidden_field">
</form>
<script>
SendHiddenFields();
</script>
</html>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 30, 2007 May 30, 2007
It sounds like you are confusing the client-side with the server-side.

Like Ian said - Javascript runs on the client (aka the browser). It allows you to do all sorts of cool things without the user having to change pages and sending another request to the server.

Conversely, CF lives on your server. Unless you send data to the server (via URL or Form post), coldfusion can't do anything with it because it doesn't have access to it.

From what it sounds like, your project would be a good match for AJAX - a methodology that uses a special javascript object to actually send data to a server side application server (in our case, ColdFusion) without having to reload the page. AJAX can be a little tricky if you are still not clear on the difference between client and server side. But there are a number of decent CF friendly frameworks out there. Search these forums for AJAX recommendations - I know there have been a bunch of threads on that topic
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources