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

hidden form objects

Status
Not open for further replies.

plotzer

Programmer
Aug 28, 2001
35
US
I am in the process of devloping an browser application that relies on using hidden form objects to pass parameters. I was wondering if anyone had an idea on what would be the best way to dynamically change these hidden objects with a mouse click on a button prior to a form submit. I was considering using DHTML, but I am not sure if this is the best option.

I would want to do something like this:
change:
<input type=&quot;hidden&quot; name=&quot;mode&quot; value=&quot;browse&quot;>

to:

<input type=&quot;hidden&quot; name=&quot;mode&quot; value=&quot;query&quot;>

by clicking a form button.

Let me know if anyone has any ideas on the best way to do this.
 
call a procedure on the button click
function changeIT()
{
var obj;
obj = document.GetElementById(&quot;mode&quot;);
mode.value = 'query';
}

NB as well as a name attribute, set an id attribute on the element
 
Will calling the function maintain the change to hidden form object or will it revert to its value that is set in html after the button is clicked. I would like to maintain the change if possible.

Thanks
 

setting the value as above will change the value and maintain it while that page is in the browser.

If you refresh the page, then the default values (the html you wrote) will apply
 
Actually,

That worked fine, but now that I've implemented it I've realized that what I really need to do is maintain the altered hidden objects after the page has refreshed. Do I need to use frames to maintain these variables after refresh?

Thanks
 

you could set a cookie, and pick up the value of that cookie when the page is loaded.
Only problem with this is you will pick up values from a previous visit to the page.

Are your users just going to use the refresh button, or will the page be submitted back to the server? If the latter, could catch the new values server side.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top