Change Checkbox Checked Value based upon variable passed by href

天涯浪子 提交于 2019-12-12 01:28:17

问题


Using Javascript and HTML Form

Page 1: Simple Link passing two variables (page1var1=xxxx and page1var=yyyy) separated by an "&" symbol

Page 2: Use Javascript to "split" the two variables either side of the "&" into page2var1 and page2var2

So now page2var1=xxxx and page2var2=yyyy (successfully done already)

How do I use these variables in page 2 to:

  1. Check a form input checkbox (i.e. "put a tick in the box") which has the ID/Name) Page2var1 (i.e. xxxx)
  2. Put the variable page2var2 (i.e. yyyy) into the value of a fixed form textarea

回答1:


Something like this:

document.GetElementById(Page2var1).checked = true;
document.GetElementById(page2var2).value = 'whatever text'

Nothing google wouldn't help you with.



来源:https://stackoverflow.com/questions/6810182/change-checkbox-checked-value-based-upon-variable-passed-by-href

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!