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

a links function in a form

Status
Not open for further replies.

verman8

Programmer
Jul 20, 2004
5
US
What is necessary to make a link create a hidden field like this: <input name="show" type="hidden" value="ang"> (the value is dynamically created) and then submit it like this would: <input name=show_search type=submit>?

 
Hi,

Sorry,Could be little bit more clear with the Question. It always helps.

Cheers,
Venu
 
it took a while, but i finally figured out the javascript. sry I wasn't clear enough.
 
Sure. I started with this code, which is creating a list box:

<SELECT NAME=show SIZE=15>
<OPTION VALUE=anc> Anchorman
...
</SELECT>

<input type=submit name=show_update value="Edit Show"> &nbsp;&nbsp;
<input type=submit name=show_create value="Create New Show">

(there are more options, but I'm simpifying it for the sake of space) so when one option is selected, the corresponding value is linked to the name show. Then you have the two submit buttons, which when pressed reload the page, and then are requested to see what changed, and to see what in the jsp page is needed to be loaded. That was working before, but I was asked to change that table to dynamically created hyperlinks (easily done with jsp and a for loop). So here's what I came up with:

function submitshow (show)
{
document.SubmitIt.show.value = show ;
document.SubmitIt.submit() ;
}
function createshow ()
{
document.SubmitIt.job.name = "show_create" ;
document.SubmitIt.submit() ;
}

<input type="hidden" id="show" name="show" value="">
<input type="hidden" id="job" name="show_update">
<a href="javascript:createshow()">*create new*</a>
<br><a href="javascript:submitshow('anc')">anc</a>

so instead of using the table and submit buttons, I was able to use hidden values/names and javascript to do the same thing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top